Skip to content

Commit f81221a

Browse files
authored
Merge pull request #72 from aeviiq/master
update 3.2
2 parents 8426bcc + 7690e64 commit f81221a

File tree

8 files changed

+27
-49
lines changed

8 files changed

+27
-49
lines changed

src/Collection.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@
66
use Aeviiq\Collection\Exception\LogicException;
77

88
/**
9-
* @psalm-template TKey as array-key
10-
* @psalm-template TValue
9+
* @template TKey as array-key
10+
* @template TValue
1111
* @phpstan-template TKey
1212
* @phpstan-template TValue
1313
*
14-
* @psalm-implements CollectionInterface<TKey, TValue>
14+
* @implements CollectionInterface<TKey, TValue>
1515
* @phpstan-implements CollectionInterface<TKey, TValue>
1616
*/
1717
class Collection implements CollectionInterface
1818
{
1919
/**
20-
* @psalm-var array<TKey, TValue>
20+
* @var array<TKey, TValue>
2121
* @phpstan-var array<TKey, TValue>
2222
*
2323
* @var array<string|int, mixed>
2424
*/
2525
private $elements;
2626

2727
/**
28-
* @psalm-var class-string<\ArrayAccess>|string
28+
* @var class-string<\ArrayAccess>|string
2929
* @phpstan-var class-string<\ArrayAccess>|string
3030
*
3131
* @var string
3232
*/
3333
private $iteratorClass;
3434

3535
/**
36-
* @psalm-param array<TKey, TValue> $elements
36+
* @param array<TKey, TValue> $elements
3737
* @phpstan-param array<TKey, TValue> $elements
3838
*
39-
* @psalm-param class-string<\ArrayAccess>|string $iteratorClass
39+
* @param class-string<\ArrayAccess>|string $iteratorClass
4040
* @phpstan-param class-string<\ArrayAccess>|string $iteratorClass
4141
*
4242
* @param array<string|int, mixed> $elements
@@ -79,7 +79,7 @@ public function last()
7979
public function remove($element): void
8080
{
8181
/**
82-
* @psalm-var TKey $key
82+
* @var TKey $key
8383
* @phpstan-var TKey $key
8484
*/
8585
$key = \array_search($element, $this->elements, true);
@@ -157,7 +157,7 @@ public function clear(): void
157157
public function getKeys(): array
158158
{
159159
/**
160-
* @psalm-var array<int, TKey>
160+
* @var array<int, TKey>
161161
* @phpstan-var array<int, TKey>
162162
*/
163163
return \array_keys($this->elements);
@@ -343,7 +343,7 @@ public function uksort(callable $func): void
343343
}
344344

345345
/**
346-
* @psalm-param TValue $element
346+
* @param TValue $element
347347
* @phpstan-param TValue $element
348348
*
349349
* @param mixed $element
@@ -355,12 +355,10 @@ protected function validateElement($element): void
355355
}
356356

357357
/**
358-
* @psalm-param array<TKey, TValue> $elements
359358
* @phpstan-param array<TKey, TValue> $elements
360359
*
361360
* @param array<string|int, mixed> $elements
362361
*
363-
* @psalm-return self<TKey, TValue>
364362
* @phpstan-return self<TKey, TValue>
365363
*/
366364
protected function createFrom(array $elements): self
@@ -369,7 +367,7 @@ protected function createFrom(array $elements): self
369367
}
370368

371369
/**
372-
* @psalm-param array<TKey, TValue> $elements
370+
* @param array<TKey, TValue> $elements
373371
* @phpstan-param array<TKey, TValue> $elements
374372
*
375373
* @param array<string|int, mixed> $elements

src/CollectionInterface.php

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,40 @@
66
use Aeviiq\Collection\Exception\LogicException;
77

88
/**
9-
* @psalm-template TKey as array-key
10-
* @psalm-template TValue
9+
* @template TKey as array-key
10+
* @template TValue
1111
* @phpstan-template TKey
1212
* @phpstan-template TValue
1313
*
14-
* @psalm-extends \IteratorAggregate<TKey, TValue>
15-
* @psalm-extends \ArrayAccess<TKey, TValue>
14+
* @extends \IteratorAggregate<TKey, TValue>
15+
* @extends \ArrayAccess<TKey, TValue>
1616
* @phpstan-extends \IteratorAggregate<TKey, TValue>
1717
* @phpstan-extends \ArrayAccess<TKey, TValue>
1818
*/
1919
interface CollectionInterface extends SortableInterface, \IteratorAggregate, \ArrayAccess, \Countable
2020
{
2121
/**
22-
* @psalm-return array<TKey, TValue>
2322
* @phpstan-return array<TKey, TValue>
2423
*
2524
* @return array<string|int, mixed>
2625
*/
2726
public function toArray(): array;
2827

2928
/**
30-
* @psalm-return TValue|null
3129
* @phpstan-return TValue|null
3230
*
3331
* @return mixed The first element in the collection or null if there is none.
3432
*/
3533
public function first();
3634

3735
/**
38-
* @psalm-return TValue|null
3936
* @phpstan-return TValue|null
4037
*
4138
* @return mixed The last element in the collection or null if there is none.
4239
*/
4340
public function last();
4441

4542
/**
46-
* @psalm-param TValue $element
4743
* @phpstan-param TValue $element
4844
*
4945
* @param mixed $element The value of the element you wish to remove.
@@ -52,15 +48,13 @@ public function last();
5248
public function remove($element): void;
5349

5450
/**
55-
* @psalm-return array<TKey, mixed>
5651
* @phpstan-return array<TKey, mixed>
5752
*
5853
* @return array<string|int, mixed>
5954
*/
6055
public function map(\Closure $closure): array;
6156

6257
/**
63-
* @psalm-return self<TKey, TValue>
6458
* @phpstan-return self<TKey, TValue>
6559
*/
6660
public function filter(\Closure $closure): CollectionInterface;
@@ -69,9 +63,6 @@ public function filter(\Closure $closure): CollectionInterface;
6963
* Merges the input with the collection. This can take an array with valid values or
7064
* an instance of the collection itself.
7165
*
72-
* @psalm-param array<TKey, TValue>|self<TKey, TValue> $input
73-
* @phpstan-param array<TKey, TValue>|self<TKey, TValue> $input
74-
*
7566
* @param array<string|int, mixed>|CollectionInterface $input
7667
*
7768
* @throws InvalidArgumentException When the $input is not of the expected type(s).
@@ -84,7 +75,6 @@ public function merge($input): void;
8475
public function isEmpty(): bool;
8576

8677
/**
87-
* @psalm-param TValue $element
8878
* @phpstan-param TValue $element
8979
*
9080
* @param mixed $element
@@ -99,23 +89,20 @@ public function contains($element): bool;
9989
public function clear(): void;
10090

10191
/**
102-
* @psalm-return array<int, TKey>
10392
* @phpstan-return array<int, TKey>
10493
*
10594
* @return array<int, int|string>
10695
*/
10796
public function getKeys(): array;
10897

10998
/**
110-
* @psalm-return array<int, TValue>
11199
* @phpstan-return array<int, TValue>
112100
*
113101
* @return array<int, mixed>
114102
*/
115103
public function getValues(): array;
116104

117105
/**
118-
* @psalm-return TValue
119106
* @phpstan-return TValue
120107
*
121108
* @return mixed The one element that was found using the closure.
@@ -125,15 +112,13 @@ public function getValues(): array;
125112
public function getOneBy(\Closure $closure);
126113

127114
/**
128-
* @psalm-return TValue|null
129115
* @phpstan-return TValue|null
130116
*
131117
* @return mixed The one element that was found using the closure or null if none was found.
132118
*/
133119
public function getOneOrNullBy(\Closure $closure);
134120

135121
/**
136-
* @psalm-param array<TKey, TValue> $elements
137122
* @phpstan-param array<TKey, TValue> $elements
138123
*
139124
* @param array<string|int, mixed> $elements
@@ -143,23 +128,20 @@ public function getOneOrNullBy(\Closure $closure);
143128
public function exchangeArray(array $elements): void;
144129

145130
/**
146-
* @psalm-param TValue $element
147131
* @phpstan-param TValue $element
148132
*
149133
* @param mixed $element
150134
*/
151135
public function append($element): void;
152136

153137
/**
154-
* @psalm-param class-string<ArrayAccess>|string $iteratorClass
155138
* @phpstan-param class-string<ArrayAccess>|string $iteratorClass
156139
*
157140
* @throws InvalidArgumentException When the given iterator class does not implement ArrayAccess.
158141
*/
159142
public function setIteratorClass(string $iteratorClass): void;
160143

161144
/**
162-
* @psalm-return self<TKey, TValue>
163145
* @phpstan-return self<TKey, TValue>
164146
*/
165147
public function copy(): CollectionInterface;

src/FloatCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Aeviiq\Collection\Exception\InvalidArgumentException;
66

77
/**
8-
* @psalm-extends Collection<array-key, float>
8+
* @extends Collection<array-key, float>
99
* @phpstan-extends Collection<array-key, float>
1010
*
1111
* @method \ArrayIterator|array<string|int, float> getIterator()

src/ImmutableCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Aeviiq\Collection\Exception\BadMethodCallException;
66

77
/**
8-
* @psalm-template TKey as array-key
9-
* @psalm-template TValue
8+
* @template TKey as array-key
9+
* @template TValue
1010
* @phpstan-template TKey
1111
* @phpstan-template TValue
1212
*
13-
* @psalm-extends Collection<TKey, TValue>
13+
* @extends Collection<TKey, TValue>
1414
* @phpstan-extends Collection<TKey, TValue>
1515
*/
1616
class ImmutableCollection extends Collection

src/ImmutableObjectCollection.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Aeviiq\Collection\Exception\InvalidArgumentException;
66

77
/**
8-
* @psalm-template TKey as array-key
9-
* @psalm-template TValue of object
8+
* @template TKey as array-key
9+
* @template TValue of object
1010
* @phpstan-template TKey
1111
* @phpstan-template TValue of object
1212
*
13-
* @psalm-extends ImmutableCollection<TKey, TValue>
13+
* @extends ImmutableCollection<TKey, TValue>
1414
* @phpstan-extends ImmutableCollection<TKey, TValue>
1515
*/
1616
class ImmutableObjectCollection extends ImmutableCollection
@@ -33,7 +33,6 @@ protected function validateElement($element): void
3333
/**
3434
* If this is kept empty, any element can be passed, as long as it is an object.
3535
*
36-
* @psalm-return class-string<TValue>|string
3736
* @phpstan-return class-string<TValue>|string
3837
*
3938
* @return string The class name of the allowed object instance.

src/IntCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Aeviiq\Collection\Exception\InvalidArgumentException;
66

77
/**
8-
* @psalm-extends Collection<array-key, int>
8+
* @extends Collection<array-key, int>
99
* @phpstan-extends Collection<array-key, int>
1010
*
1111
* @method \ArrayIterator|array<string|int, int> getIterator()

src/ObjectCollection.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Aeviiq\Collection\Exception\InvalidArgumentException;
66

77
/**
8-
* @psalm-template TKey as array-key
9-
* @psalm-template TValue of object
8+
* @template TKey as array-key
9+
* @template TValue of object
1010
* @phpstan-template TKey
1111
* @phpstan-template TValue of object
1212
*
13-
* @psalm-extends Collection<TKey, TValue>
13+
* @extends Collection<TKey, TValue>
1414
* @phpstan-extends Collection<TKey, TValue>
1515
*
1616
* @method \ArrayIterator|array<string|int, object> getIterator()
@@ -37,7 +37,6 @@ protected function validateElement($element): void
3737
/**
3838
* If this is kept empty, any element can be passed, as long as it is an object.
3939
*
40-
* @psalm-return class-string<TValue>|string
4140
* @phpstan-return class-string<TValue>|string
4241
*
4342
* @return string The class name of the allowed object instance.

src/StringCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Aeviiq\Collection\Exception\InvalidArgumentException;
66

77
/**
8-
* @psalm-extends Collection<array-key, string>
8+
* @extends Collection<array-key, string>
99
* @phpstan-extends Collection<array-key, string>
1010
*
1111
* @method \ArrayIterator|array<string|int, string> getIterator()

0 commit comments

Comments
 (0)