Skip to content

Commit

Permalink
fix: Update PHPStan configuration (#183)
Browse files Browse the repository at this point in the history
* fix: Fix constant type typo.

* chore: Update PSalm baseline now that phpstan/phpstan#5372 has been fixed and released.

* fix: Update SA tests accordingly.
  • Loading branch information
drupol authored Aug 22, 2021
1 parent 5a8c46a commit 6732261
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 57 deletions.
46 changes: 0 additions & 46 deletions phpstan-unsupported-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,3 @@ parameters:
message: "#^PHPDoc tag @template T for class loophp\\\\collection\\\\Operation\\\\Unpack with bound type array\\<int, NewT\\|NewTKey\\> is not supported\\.$#"
count: 1
path: src/Operation/Unpack.php

-
message: "#^Parameter \\#1 \\$collection of function reduce_checkMapString expects loophp\\\\collection\\\\Contract\\\\Collection\\<string, string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<string, non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/reduce.php

-
message: "#^Parameter \\#1 \\$collection of function reduction_checkListString expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/reduction.php

-
message: "#^Parameter \\#1 \\$collection of function reduction_checkListStringWithNull expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/reduction.php

-
message: "#^Parameter \\#1 \\$collection of function scanLeft_checkListOfSize1String expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, bool\\|string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, bool\\|non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/scanLeft.php

-
message: "#^Parameter \\#1 \\$collection of function scanLeft_checkListStringWithNull expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, string\\|null\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, non\\-empty\\-string\\|null\\> given\\.$#"
count: 1
path: tests/static-analysis/scanLeft.php

-
message: "#^Parameter \\#1 \\$collection of function scanLeft1_checkListOfSize1String expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, int\\|string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, int\\|non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/scanLeft1.php

-
message: "#^Parameter \\#1 \\$collection of function scanRight_checkListOfSize1String expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, bool\\|string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, bool\\|non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/scanRight.php

-
message: "#^Parameter \\#1 \\$collection of function scanRight_checkListStringWithNull expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, string\\|null\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, non\\-empty\\-string\\|null\\> given\\.$#"
count: 1
path: tests/static-analysis/scanRight.php

-
message: "#^Parameter \\#1 \\$collection of function scanRight1_checkListOfSize1String expects loophp\\\\collection\\\\Contract\\\\Collection\\<int, int\\|string\\>, loophp\\\\collection\\\\Contract\\\\Collection\\<int, int\\|non\\-empty\\-string\\> given\\.$#"
count: 1
path: tests/static-analysis/scanRight1.php

2 changes: 1 addition & 1 deletion src/Operation/Nullsy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
final class Nullsy extends AbstractOperation
{
/**
* @param list<null, array, int, bool, string>
* @var list<null, array, int, bool, string>
*/
public const VALUES = [null, [], 0, false, ''];

Expand Down
6 changes: 3 additions & 3 deletions tests/static-analysis/asyncMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ function asyncMap_checkListInt(CollectionInterface $collection): void
{
}
/**
* @param CollectionInterface<int, non-empty-string> $collection
* @param CollectionInterface<int, string> $collection
*/
function asyncMap_checkListString(CollectionInterface $collection): void
{
}
/**
* @param CollectionInterface<string, non-empty-string> $collection
* @param CollectionInterface<string, string> $collection
*/
function asyncMap_checkMapString(CollectionInterface $collection): void
{
Expand Down Expand Up @@ -54,7 +54,7 @@ function asyncMap_checkMapClass(CollectionInterface $collection): void

// This should work but static analysers restrict the return type
// E.g: `numeric&string` or `non-empty-string`
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
asyncMap_checkListString(Collection::fromIterable([1, 2, 3])->asyncMap($toString));
/** @psalm-suppress InvalidArgument */
asyncMap_checkMapString(Collection::fromIterable(['foo' => 'bar', 'baz' => 'bar'])->asyncMap($appendBar));
Expand Down
6 changes: 3 additions & 3 deletions tests/static-analysis/flatMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ function flatMap_checkMapString(CollectionInterface $collection): void

// This should work but static analysers restrict the return type
// E.g: `numeric&string` or `non-empty-string`
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
flatMap_checkListString(Collection::fromIterable([1, 2, 3])->flatMap($toString));
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
flatMap_checkListString(Collection::fromIterable(['foo', 'bar'])->flatMap($appendBar));
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
flatMap_checkListString(Collection::fromIterable([1, 2, 3])->flatMap($square)->flatMap($toString)->flatMap($appendBar));

// VALID failures due to usage with wrong types
Expand Down
8 changes: 4 additions & 4 deletions tests/static-analysis/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ function map_checkMapClass(CollectionInterface $collection): void

// This should work but static analysers restrict the return type
// E.g: `numeric&string` or `non-empty-string`
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
map_checkListString(Collection::fromIterable([1, 2, 3])->map($toString));
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
map_checkMapString(Collection::fromIterable(['foo' => 'bar', 'baz' => 'bar'])->map($appendBar));
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
map_checkListString(Collection::fromIterable(['foo', 'bar'])->map($appendBar));
/** @psalm-suppress InvalidArgument @phpstan-ignore-next-line */
/** @psalm-suppress InvalidArgument */
map_checkListString(Collection::fromIterable([1, 2, 3])->map($square)->map($toString)->map($appendBar));

// VALID failures due to usage with wrong types
Expand Down

0 comments on commit 6732261

Please sign in to comment.