Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions phpstan.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,6 @@ parameters:
count: 1
path: src/Domain/Account/Adapters/AccountPermission.php

-
message: '#^Instanceof between SP\\Domain\\Common\\Models\\Item and SP\\Domain\\Common\\Models\\Item will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
count: 1
path: src/Domain/Account/Dtos/AccountEnrichedDto.php

-
message: '#^Instanceof between SP\\Domain\\Account\\Dtos\\AccountUpdateDto and SP\\Domain\\Account\\Dtos\\AccountUpdateDto will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
Expand Down
13 changes: 11 additions & 2 deletions src/Domain/Common/Dtos/ItemDataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@
trait ItemDataTrait
{
/**
* @param Item[] $items
* Keep only the `Item`s out of whatever was handed over.
*
* The parameter is deliberately `mixed[]` rather than `Item[]`: every caller takes a bare
* `array` at runtime — `AccountAclDto`'s constructor and `AccountEnrichedDto`'s `with*()`
* methods all declare `array $x` — and the values arrive from the database and from
* deserialized DTOs, so this filter is the thing that makes the array an `Item[]`. Annotating
* the input as `Item[]` claimed the guarantee this method exists to provide, which is why
* PHPStan 2.2.12 began reporting the `instanceof` as always true.
*
* @param mixed[] $items
*
* @return Item[]
*/
private static function buildFromItemData(array $items): array
{
return array_filter($items, static fn($value) => $value instanceof Item);
return array_filter($items, static fn(mixed $value): bool => $value instanceof Item);
}
}