Skip to content

Commit

Permalink
bump phpstan levet to 6 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas authored Dec 8, 2024
1 parent b897c5c commit 3191002
Show file tree
Hide file tree
Showing 21 changed files with 285 additions and 149 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"friendsofphp/php-cs-fixer": "^3.27",
"nette/php-generator": "^4.0",
"phpunit/phpunit": "^10.5",
"phpstan/phpstan": "^2.0"
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 9 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
phpVersion: 80100
level: 5
level: 6
paths:
- src
- tests
- generators
ignoreErrors:
-
identifier: argument.templateType
path: tests/Collection/MapTest.php
-
identifier: missingType.generics
path: src/Collection/Stream/Collectors.php
14 changes: 9 additions & 5 deletions src/Collection/GenericList.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ abstract class GenericList extends Sequence
*
* @param U ...$elements
*
* @return GenericList<U>
* @return self<U>
*/
public static function of(...$elements): self
{
return self::ofAll($elements);
}

/**
* @return self<T>
*/
public static function empty(): self
{
return Nil::instance();
Expand All @@ -36,7 +39,7 @@ public static function empty(): self
*
* @param iterable<U> $elements
*
* @return GenericList<U>
* @return self<U>
*/
public static function ofAll(iterable $elements): self
{
Expand Down Expand Up @@ -65,7 +68,7 @@ public static function range(int $start, int $end): self
*
* @param callable(T):U $mapper
*
* @return GenericList<U>
* @return self<U>
*/
public function map(callable $mapper): self
{
Expand All @@ -81,10 +84,11 @@ public function map(callable $mapper): self
*
* @param callable(T): Traversable<U> $mapper
*
* @return GenericList<U>
* @return self<U>
*/
public function flatMap(callable $mapper)
{
/** @var self<U> $list */
$list = self::empty();
foreach ($this as $value) {
foreach ($mapper($value) as $mapped) {
Expand All @@ -98,7 +102,7 @@ public function flatMap(callable $mapper)
/**
* @param callable(T):bool $predicate
*
* @return GenericList<T>
* @return self<T>
*/
public function filter(callable $predicate)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Collection/GenericList/Nil.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ private function __construct()
{
}

/**
* @return self<T>
*/
public static function instance(): self
{
return new self();
Expand Down
12 changes: 12 additions & 0 deletions src/Collection/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* @template T
*
* @implements \Iterator<int, T>
*/
class Iterator implements \Iterator
{
Expand Down Expand Up @@ -51,11 +53,21 @@ public static function of(...$elements): self
return new ArrayIterator($elements);
}

/**
* @return self<T>
*/
public static function empty(): self
{
return EmptyIterator::instance();
}

/**
* @template U
*
* @param iterable<U> $elements
*
* @return self<U>
*/
public static function fromIterable(iterable $elements): self
{
if ($elements instanceof self) {
Expand Down
12 changes: 11 additions & 1 deletion src/Collection/Iterator/EmptyIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
use Munus\Collection\Iterator;
use Munus\Exception\NoSuchElementException;

/**
* @template T
*
* @template-extends Iterator<T>
*/
final class EmptyIterator extends Iterator
{
private function __construct()
{
}

/**
* @return self<T>
*/
public static function instance(): self
{
return new self();
Expand All @@ -24,7 +32,9 @@ public function hasNext(): bool
}

/**
* @return void
* @throws NoSuchElementException
*
* @return never-return
*/
public function next()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Collection/Iterator/MapIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
/**
* @template K
* @template V
*
* @template-extends Iterator<Tuple2<K, V>>
*/
final class MapIterator extends Iterator
{
Expand Down
2 changes: 2 additions & 0 deletions src/Collection/Iterator/SingletonIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* @template T
*
* @template-extends Iterator<T>
*/
final class SingletonIterator extends Iterator
{
Expand Down
Loading

0 comments on commit 3191002

Please sign in to comment.