Skip to content

Commit 3191002

Browse files
authored
bump phpstan levet to 6 (#115)
1 parent b897c5c commit 3191002

File tree

21 files changed

+285
-149
lines changed

21 files changed

+285
-149
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"friendsofphp/php-cs-fixer": "^3.27",
1717
"nette/php-generator": "^4.0",
1818
"phpunit/phpunit": "^10.5",
19-
"phpstan/phpstan": "^2.0"
19+
"phpstan/phpstan": "^2.0",
20+
"phpstan/phpstan-phpunit": "^2.0"
2021
},
2122
"autoload": {
2223
"psr-4": {

phpstan.neon

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
includes:
22
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
3+
- vendor/phpstan/phpstan-phpunit/extension.neon
34
parameters:
45
phpVersion: 80100
5-
level: 5
6+
level: 6
67
paths:
78
- src
89
- tests
910
- generators
11+
ignoreErrors:
12+
-
13+
identifier: argument.templateType
14+
path: tests/Collection/MapTest.php
15+
-
16+
identifier: missingType.generics
17+
path: src/Collection/Stream/Collectors.php

src/Collection/GenericList.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ abstract class GenericList extends Sequence
1919
*
2020
* @param U ...$elements
2121
*
22-
* @return GenericList<U>
22+
* @return self<U>
2323
*/
2424
public static function of(...$elements): self
2525
{
2626
return self::ofAll($elements);
2727
}
2828

29+
/**
30+
* @return self<T>
31+
*/
2932
public static function empty(): self
3033
{
3134
return Nil::instance();
@@ -36,7 +39,7 @@ public static function empty(): self
3639
*
3740
* @param iterable<U> $elements
3841
*
39-
* @return GenericList<U>
42+
* @return self<U>
4043
*/
4144
public static function ofAll(iterable $elements): self
4245
{
@@ -65,7 +68,7 @@ public static function range(int $start, int $end): self
6568
*
6669
* @param callable(T):U $mapper
6770
*
68-
* @return GenericList<U>
71+
* @return self<U>
6972
*/
7073
public function map(callable $mapper): self
7174
{
@@ -81,10 +84,11 @@ public function map(callable $mapper): self
8184
*
8285
* @param callable(T): Traversable<U> $mapper
8386
*
84-
* @return GenericList<U>
87+
* @return self<U>
8588
*/
8689
public function flatMap(callable $mapper)
8790
{
91+
/** @var self<U> $list */
8892
$list = self::empty();
8993
foreach ($this as $value) {
9094
foreach ($mapper($value) as $mapped) {
@@ -98,7 +102,7 @@ public function flatMap(callable $mapper)
98102
/**
99103
* @param callable(T):bool $predicate
100104
*
101-
* @return GenericList<T>
105+
* @return self<T>
102106
*/
103107
public function filter(callable $predicate)
104108
{

src/Collection/GenericList/Nil.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ private function __construct()
1818
{
1919
}
2020

21+
/**
22+
* @return self<T>
23+
*/
2124
public static function instance(): self
2225
{
2326
return new self();

src/Collection/Iterator.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* @template T
14+
*
15+
* @implements \Iterator<int, T>
1416
*/
1517
class Iterator implements \Iterator
1618
{
@@ -51,11 +53,21 @@ public static function of(...$elements): self
5153
return new ArrayIterator($elements);
5254
}
5355

56+
/**
57+
* @return self<T>
58+
*/
5459
public static function empty(): self
5560
{
5661
return EmptyIterator::instance();
5762
}
5863

64+
/**
65+
* @template U
66+
*
67+
* @param iterable<U> $elements
68+
*
69+
* @return self<U>
70+
*/
5971
public static function fromIterable(iterable $elements): self
6072
{
6173
if ($elements instanceof self) {

src/Collection/Iterator/EmptyIterator.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
use Munus\Collection\Iterator;
88
use Munus\Exception\NoSuchElementException;
99

10+
/**
11+
* @template T
12+
*
13+
* @template-extends Iterator<T>
14+
*/
1015
final class EmptyIterator extends Iterator
1116
{
1217
private function __construct()
1318
{
1419
}
1520

21+
/**
22+
* @return self<T>
23+
*/
1624
public static function instance(): self
1725
{
1826
return new self();
@@ -24,7 +32,9 @@ public function hasNext(): bool
2432
}
2533

2634
/**
27-
* @return void
35+
* @throws NoSuchElementException
36+
*
37+
* @return never-return
2838
*/
2939
public function next()
3040
{

src/Collection/Iterator/MapIterator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
/**
1212
* @template K
1313
* @template V
14+
*
15+
* @template-extends Iterator<Tuple2<K, V>>
1416
*/
1517
final class MapIterator extends Iterator
1618
{

src/Collection/Iterator/SingletonIterator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
/**
1111
* @template T
12+
*
13+
* @template-extends Iterator<T>
1214
*/
1315
final class SingletonIterator extends Iterator
1416
{

0 commit comments

Comments
 (0)