Skip to content

Commit f9b55e8

Browse files
committed
PHPStan fixes.
1 parent 9dedfbd commit f9b55e8

20 files changed

Lines changed: 28 additions & 25 deletions

src/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use IterTools\Util\ResourcePolicy;
88

9-
class File
9+
final class File
1010
{
1111
/**
1212
* Iterate the lines of a file, read in from a file handle stream resource.

src/Infinite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace IterTools;
66

7-
class Infinite
7+
final class Infinite
88
{
99
/**
1010
* Count sequentially forever
@@ -45,7 +45,7 @@ public static function cycle(iterable $iterable): \InfiniteIterator
4545
*/
4646
public static function repeat(mixed $item): \Generator
4747
{
48-
// @phpstan-ignore-next-line
48+
/** @phpstan-ignore while.alwaysTrue */
4949
while (true) {
5050
yield $item;
5151
}

src/Math.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use IterTools\Util\UniqueExtractor;
88

9-
class Math
9+
final class Math
1010
{
1111
/**
1212
* Returns a frequency distribution of iterable elements

src/Multi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use IterTools\Util\Iterators\StrictMultipleIterator;
99
use IterTools\Util\NoValueMonad;
1010

11-
class Multi
11+
final class Multi
1212
{
1313
/**
1414
* Iterate multiple iterable collections simultaneously.

src/Random.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace IterTools;
66

7-
class Random
7+
final class Random
88
{
99
/**
1010
* Generate random selections from an array of values

src/Reduce.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use IterTools\Util\NoValueMonad;
88

9-
class Reduce
9+
final class Reduce
1010
{
1111
/**
1212
* Reduces given collection like array_reduce() function.
@@ -98,6 +98,7 @@ public static function toMax(iterable $data, ?callable $compareBy = null): mixed
9898
* @param callable|null $compareBy
9999
*
100100
* @return array{numeric, numeric}|array{null, null}
101+
* @phpstan-ignore return.unusedType
101102
*/
102103
public static function toMinMax(iterable $numbers, ?callable $compareBy = null): array
103104
{
@@ -147,6 +148,7 @@ public static function toCount(iterable $data): int
147148
* @param iterable<numeric> $data
148149
*
149150
* @return int|float
151+
* @phpstan-ignore return.unusedType
150152
*/
151153
public static function toSum(iterable $data): int|float
152154
{
@@ -162,6 +164,7 @@ public static function toSum(iterable $data): int|float
162164
* @param iterable<numeric> $data
163165
*
164166
* @return int|float|null
167+
* @phpstan-ignore return.unusedType, return.unusedType
165168
*/
166169
public static function toProduct(iterable $data): int|float|null
167170
{

src/Set.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use IterTools\Util\UniqueExtractor;
1010
use IterTools\Util\UsageMap;
1111

12-
class Set
12+
final class Set
1313
{
1414
/**
1515
* Iterate only the distinct elements.

src/Single.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use IterTools\Util\UniqueExtractor;
88

9-
class Single
9+
final class Single
1010
{
1111
/**
1212
* Iterate the individual characters of a string

src/Sort.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace IterTools;
66

7-
class Sort
7+
final class Sort
88
{
99
/**
1010
* Sorts the given iterable, maintaining index key associations.

src/Stream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @implements \IteratorAggregate<mixed>
1313
*/
14-
class Stream implements \IteratorAggregate
14+
final class Stream implements \IteratorAggregate
1515
{
1616
/**
1717
* @var iterable<mixed> iterable source
@@ -1128,7 +1128,7 @@ public function toFile(mixed $fileResource, string $newlineSeparator = \PHP_EOL,
11281128
}
11291129

11301130
foreach ($this->iterable as $line) {
1131-
// @phpstan-ignore-next-line
1131+
/** @phpstan-ignore argument.type */
11321132
$line = \is_float($line) && \is_nan($line) ? 'NAN' : \strval($line);
11331133

11341134
if ($firstIteration) {

0 commit comments

Comments
 (0)