diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml
index 257b4a0..aee3d82 100644
--- a/.github/workflows/mutation.yml
+++ b/.github/workflows/mutation.yml
@@ -6,7 +6,7 @@ on:
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- - 'psalm.xml'
+ - 'phpstan.neon'
push:
branches: ['master']
@@ -16,7 +16,7 @@ on:
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- - 'psalm.xml'
+ - 'phpstan.neon'
name: mutation test
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index cab5775..eb3fbf3 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -26,10 +26,10 @@ permissions:
contents: read
jobs:
- psalm:
- uses: yiisoft/actions/.github/workflows/psalm.yml@master
+ phpstan:
+ uses: yiisoft/actions/.github/workflows/phpstan.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
- ['8.1', '8.2', '8.3', '8.4']
+ ['8.1', '8.2', '8.3', '8.4', '8.5']
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e14577..2b1a1e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
## 2.0.1 under development
+- Chg #259: Replace Psalm with PHPStan (@vjik)
- Enh #246: Explicitly import functions and constants in "use" section (@mspirkov)
+- Enh #259: Remove redundant `instanceof LimitableDataInterface` check in `OffsetPaginator::isSortable()` (@vjik)
## 2.0.0 December 13, 2025
diff --git a/README.md b/README.md
index 8ba389c..07391ee 100644
--- a/README.md
+++ b/README.md
@@ -12,8 +12,6 @@
[](https://codecov.io/gh/yiisoft/data)
[](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/data/master)
[](https://github.com/yiisoft/data/actions?query=workflow%3A%22static+analysis%22)
-[](https://shepherd.dev/github/yiisoft/data)
-[](https://shepherd.dev/github/yiisoft/data)
The package provides generic data abstractions. The aim is to hide a storage aspect from the operations of reading,
writing and processing data.
diff --git a/composer.json b/composer.json
index 35701e9..01d658d 100644
--- a/composer.json
+++ b/composer.json
@@ -39,6 +39,7 @@
"ext-ctype": "*",
"bamarni/composer-bin-plugin": "^1.8.3",
"friendsofphp/php-cs-fixer": "^3.95.27",
+ "phpstan/phpstan": "^2.3",
"phpunit/phpunit": "^10.5.60",
"rector/rector": "^2.7.0",
"shipmonk/composer-dependency-analyser": "^1.8",
@@ -74,6 +75,7 @@
"test-watch": "phpunit-watcher watch",
"cs-fix": "php-cs-fixer fix",
"rector": "rector",
+ "phpstan": "phpstan",
"mutation": "infection --threads=max --min-covered-msi=100",
"dependency-analyser": "composer-dependency-analyser"
}
diff --git a/docs/internals.md b/docs/internals.md
index b77907c..4ae9aeb 100644
--- a/docs/internals.md
+++ b/docs/internals.md
@@ -19,10 +19,10 @@ The package tests are checked with [Infection](https://infection.github.io/) mut
## Static analysis
-The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:
+The code is statically analyzed with [PHPStan](https://phpstan.org/). To run static analysis:
```shell
-./vendor/bin/psalm
+./vendor/bin/phpstan
```
## Code style
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..3e47faf
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,5 @@
+parameters:
+ level: max
+ treatPhpDocTypesAsCertain: false
+ paths:
+ - src
diff --git a/psalm.xml b/psalm.xml
deleted file mode 100644
index 39a3bda..0000000
--- a/psalm.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Paginator/KeysetPaginator.php b/src/Paginator/KeysetPaginator.php
index 6e6dd1b..f710b44 100644
--- a/src/Paginator/KeysetPaginator.php
+++ b/src/Paginator/KeysetPaginator.php
@@ -45,25 +45,24 @@
*
* @link https://use-the-index-luke.com/no-offset
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @implements PaginatorInterface
*
- * @psalm-type FilterCallback = Closure(GreaterThan|LessThan|GreaterThanOrEqual|LessThanOrEqual,KeysetFilterContext):FilterInterface
+ * @phpstan-type FilterCallback = Closure(GreaterThan|LessThan|GreaterThanOrEqual|LessThanOrEqual,KeysetFilterContext):FilterInterface
*/
final class KeysetPaginator implements PaginatorInterface
{
/**
* Data reader being paginated.
*
- * @psalm-var ReadableDataInterface&LimitableDataInterface&FilterableDataInterface&SortableDataInterface
+ * @var ReadableDataInterface&LimitableDataInterface&FilterableDataInterface&SortableDataInterface
*/
private ReadableDataInterface $dataReader;
/**
- * @var int Maximum number of items per page.
- * @psalm-var positive-int
+ * @var positive-int Maximum number of items per page.
*/
private int $pageSize = self::DEFAULT_PAGE_SIZE;
private ?PageToken $token = null;
@@ -81,7 +80,7 @@ final class KeysetPaginator implements PaginatorInterface
private bool $hasNextPage = false;
/**
- * @psalm-var FilterCallback|null
+ * @var FilterCallback|null
*/
private ?Closure $filterCallback = null;
@@ -89,14 +88,12 @@ final class KeysetPaginator implements PaginatorInterface
* Reader cache against repeated scans.
* See more {@see __clone()} and {@see initialize()}.
*
- * @psalm-var null|array
+ * @var null|array
*/
private ?array $readCache = null;
/**
- * @param ReadableDataInterface $dataReader Data reader being paginated.
- * @psalm-param ReadableDataInterface&LimitableDataInterface&FilterableDataInterface&SortableDataInterface $dataReader
- * @psalm-suppress DocblockTypeContradiction Needed to allow validating `$dataReader`
+ * @param ReadableDataInterface $dataReader Data reader being paginated.
*/
public function __construct(ReadableDataInterface $dataReader)
{
@@ -151,7 +148,6 @@ public function getToken(): ?PageToken
public function withPageSize(int $pageSize): static
{
- /** @psalm-suppress DocblockTypeContradiction We don't believe in psalm types */
if ($pageSize < 1) {
throw new InvalidArgumentException('Page size should be at least 1.');
}
@@ -164,7 +160,7 @@ public function withPageSize(int $pageSize): static
/**
* Returns a new instance with defined closure for preparing data reader filters.
*
- * @psalm-param FilterCallback|null $callback Closure with signature:
+ * @param FilterCallback|null $callback Closure with signature:
*
* ```php
* function(
@@ -172,6 +168,8 @@ public function withPageSize(int $pageSize): static
* KeysetFilterContext $context
* ): FilterInterface
* ```
+ *
+ * @return static New instance.
*/
public function withFilterCallback(?Closure $callback): self
{
@@ -322,7 +320,7 @@ public function isPaginationRequired(): bool
}
/**
- * @psalm-assert array $this->readCache
+ * @phpstan-assert array $this->readCache
*/
private function initialize(): void
{
@@ -341,8 +339,9 @@ private function initialize(): void
}
/**
- * @psalm-param ReadableDataInterface $dataReader
- * @psalm-return array
+ * @param ReadableDataInterface $dataReader
+ *
+ * @return array
*/
private function readData(ReadableDataInterface $dataReader, Sort $sort): array
{
@@ -350,11 +349,13 @@ private function readData(ReadableDataInterface $dataReader, Sort $sort): array
[$field] = $this->getFieldAndSortingFromSort($sort);
foreach ($dataReader->read() as $key => $item) {
+ /** @phpstan-ignore cast.string */
$this->currentFirstValue ??= (string) ArrayHelper::getValue($item, $field);
if (count($data) === $this->pageSize) {
$this->hasNextPage = true;
} else {
+ /** @phpstan-ignore cast.string */
$this->currentLastValue = (string) ArrayHelper::getValue($item, $field);
$data[$key] = $item;
}
@@ -364,8 +365,9 @@ private function readData(ReadableDataInterface $dataReader, Sort $sort): array
}
/**
- * @psalm-param array $data
- * @psalm-return array
+ * @param array $data
+ *
+ * @return array
*/
private function reverseData(array $data): array
{
@@ -375,7 +377,7 @@ private function reverseData(array $data): array
}
/**
- * @psalm-param ReadableDataInterface&LimitableDataInterface&FilterableDataInterface&SortableDataInterface $dataReader
+ * @param ReadableDataInterface&LimitableDataInterface&FilterableDataInterface&SortableDataInterface $dataReader
*/
private function previousPageExist(ReadableDataInterface $dataReader, Sort $sort): bool
{
@@ -386,9 +388,7 @@ private function previousPageExist(ReadableDataInterface $dataReader, Sort $sort
private function createFilter(Sort $sort): FilterInterface
{
- /**
- * @psalm-var PageToken $this->token The code calling this method must ensure that page token is not null.
- */
+ /** @phpstan-ignore property.nonObject (The code calling this method must ensure that page token is not null) */
$value = $this->token->value;
[$field, $sorting] = $this->getFieldAndSortingFromSort($sort);
@@ -410,9 +410,7 @@ private function createFilter(Sort $sort): FilterInterface
private function getReverseFilter(Sort $sort): FilterInterface
{
- /**
- * @psalm-var PageToken $this->token The code calling this method must ensure that page token is not null.
- */
+ /** @phpstan-ignore property.nonObject (The code calling this method must ensure that page token is not null) */
$value = $this->token->value;
[$field, $sorting] = $this->getFieldAndSortingFromSort($sort);
@@ -444,7 +442,7 @@ private function reverseSort(Sort $sort): Sort
}
/**
- * @psalm-return array{0: string, 1: int}
+ * @return array{0: string, 1: int}
*/
private function getFieldAndSortingFromSort(Sort $sort): array
{
@@ -457,8 +455,8 @@ private function getFieldAndSortingFromSort(Sort $sort): array
}
/**
- * @param FilterableDataInterface&LimitableDataInterface&ReadableDataInterface&SortableDataInterface $dataReader
- * @return FilterableDataInterface&LimitableDataInterface&ReadableDataInterface&SortableDataInterface
+ * @param FilterableDataInterface&LimitableDataInterface&ReadableDataInterface&SortableDataInterface $dataReader
+ * @return FilterableDataInterface&LimitableDataInterface&ReadableDataInterface&SortableDataInterface
*/
private function prepareSortInDataReader(ReadableDataInterface $dataReader, ?Sort $sort): ReadableDataInterface
{
diff --git a/src/Paginator/OffsetPaginator.php b/src/Paginator/OffsetPaginator.php
index 380969e..46b670e 100644
--- a/src/Paginator/OffsetPaginator.php
+++ b/src/Paginator/OffsetPaginator.php
@@ -35,8 +35,8 @@
* - Performance degrades with page number increase
* - Insertions or deletions in the middle of the data are making results inconsistent
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @implements PaginatorInterface
*/
@@ -48,22 +48,19 @@ final class OffsetPaginator implements PaginatorInterface
private PageToken $token;
/**
- * @var int Maximum number of items per page.
- * @psalm-var positive-int
+ * @var positive-int Maximum number of items per page.
*/
private int $pageSize = self::DEFAULT_PAGE_SIZE;
/**
* Data reader being paginated.
*
- * @psalm-var ReadableDataInterface&LimitableDataInterface&OffsetableDataInterface&CountableDataInterface
+ * @var ReadableDataInterface&LimitableDataInterface&OffsetableDataInterface&CountableDataInterface
*/
private ReadableDataInterface $dataReader;
/**
- * @param ReadableDataInterface $dataReader Data reader being paginated.
- * @psalm-param ReadableDataInterface&LimitableDataInterface&OffsetableDataInterface&CountableDataInterface $dataReader
- * @psalm-suppress DocblockTypeContradiction Needed to allow validating `$dataReader`
+ * @param ReadableDataInterface $dataReader Data reader being paginated.
*/
public function __construct(ReadableDataInterface $dataReader)
{
@@ -108,7 +105,6 @@ public function withToken(?PageToken $token): static
public function withPageSize(int $pageSize): static
{
- /** @psalm-suppress DocblockTypeContradiction We don't believe in psalm types */
if ($pageSize < 1) {
throw new InvalidArgumentException('Page size should be at least 1.');
}
@@ -121,17 +117,14 @@ public function withPageSize(int $pageSize): static
/**
* Get a new instance with the given current page number set.
*
- * @param int $page Page number.
+ * @param positive-int $page Page number.
*
* @throws InvalidArgumentException If page is not a positive number.
*
- * @return self New instance.
- *
- * @psalm-param positive-int $page
+ * @return static New instance.
*/
public function withCurrentPage(int $page): self
{
- /** @psalm-suppress DocblockTypeContradiction */
if ($page < 1) {
throw new InvalidArgumentException('Current page should be at least 1.');
}
@@ -180,8 +173,7 @@ public function getPageSize(): int
/**
* Get the current page number.
*
- * @return int Current page number.
- * @psalm-return positive-int
+ * @return positive-int Current page number.
*/
public function getCurrentPage(): int
{
@@ -204,7 +196,7 @@ public function getCurrentPageSize(): int
}
if ($currentPage === $pages) {
- /** @psalm-var positive-int Because the total items number is more than offset */
+ /** @var positive-int Because the total items number is more than offset */
return $this->getTotalItems() - $this->getOffset();
}
@@ -224,9 +216,7 @@ public function getOffset(): int
/**
* Get total number of items in the whole data reader being paginated.
*
- * @return int Total items number.
- *
- * @psalm-return non-negative-int
+ * @return non-negative-int Total items number.
*/
public function getTotalItems(): int
{
@@ -251,11 +241,11 @@ public function getTotalPages(): int
}
/**
- * @psalm-assert-if-true SortableDataInterface $this->dataReader
+ * @phpstan-assert-if-true SortableDataInterface $this->dataReader
*/
public function isSortable(): bool
{
- if ($this->dataReader instanceof LimitableDataInterface && $this->dataReader->getLimit() !== null) {
+ if ($this->dataReader->getLimit() !== null) {
return false;
}
@@ -279,7 +269,7 @@ public function getSort(): ?Sort
}
/**
- * @psalm-assert-if-true FilterableDataInterface $this->dataReader
+ * @phpstan-assert-if-true FilterableDataInterface $this->dataReader
*/
public function isFilterable(): bool
{
@@ -307,7 +297,7 @@ public function withFilter(FilterInterface $filter): static
}
/**
- * @psalm-return Generator
+ * @return Generator
*/
public function read(): iterable
{
@@ -320,7 +310,7 @@ public function read(): iterable
$dataReaderLimit = $this->dataReader->getLimit();
if ($dataReaderLimit !== null && ($this->getOffset() + $this->pageSize) > $dataReaderLimit) {
- /** @psalm-var non-negative-int $limit */
+ /** @var non-negative-int $limit */
$limit = $dataReaderLimit - $this->getOffset();
}
@@ -361,7 +351,7 @@ public function isPaginationRequired(): bool
}
/**
- * @psalm-return positive-int
+ * @return positive-int
*/
private function getInternalTotalPages(): int
{
diff --git a/src/Paginator/PaginatorInterface.php b/src/Paginator/PaginatorInterface.php
index 6002b74..4d792e2 100644
--- a/src/Paginator/PaginatorInterface.php
+++ b/src/Paginator/PaginatorInterface.php
@@ -16,8 +16,8 @@
* - Each page has string "tokens" for getting to the previous and next page.
* - Maximum number of items per page could be set.
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @extends ReadableDataInterface
*/
@@ -25,8 +25,6 @@ interface PaginatorInterface extends ReadableDataInterface
{
/**
* Page size that is used in case it is not set explicitly.
- *
- * @psalm-suppress MissingClassConstType
*/
public const DEFAULT_PAGE_SIZE = 10;
@@ -46,13 +44,11 @@ public function withToken(?PageToken $token): static;
/**
* Get a new instance with a page size set.
*
- * @param int $pageSize Maximum number of items per page.
+ * @param positive-int $pageSize Maximum number of items per page.
*
* @throws InvalidArgumentException If page size is not a positive number.
*
* @return static New instance.
- *
- * @psalm-param positive-int $pageSize
*/
public function withPageSize(int $pageSize): static;
@@ -96,9 +92,7 @@ public function previousPage(): ?static;
*
* @see getCurrentPageSize()
*
- * @return int Page size.
- *
- * @psalm-return positive-int
+ * @return positive-int Page size.
*/
public function getPageSize(): int;
@@ -109,9 +103,7 @@ public function getPageSize(): int;
*
* @see getPageSize()
*
- * @return int Current page size.
- *
- * @psalm-return non-negative-int
+ * @return non-negative-int Current page size.
*/
public function getCurrentPageSize(): int;
@@ -167,8 +159,7 @@ public function withFilter(FilterInterface $filter): static;
*
* @throws PageNotFoundException If the page specified isn't found.
*
- * @return iterable Iterator with items for the current page.
- * @psalm-return iterable
+ * @return iterable Iterator with items for the current page.
*/
public function read(): iterable;
diff --git a/src/Processor/DataProcessorException.php b/src/Processor/DataProcessorException.php
index 1a48ae9..76dcb32 100644
--- a/src/Processor/DataProcessorException.php
+++ b/src/Processor/DataProcessorException.php
@@ -10,7 +10,5 @@
* Exception occurred during data processing.
*
* @see DataProcessorInterface
- *
- * @psalm-suppress ClassMustBeFinal We assume that the class may be extended in userland.
*/
class DataProcessorException extends RuntimeException {}
diff --git a/src/Processor/DataProcessorInterface.php b/src/Processor/DataProcessorInterface.php
index de7d676..6676d19 100644
--- a/src/Processor/DataProcessorInterface.php
+++ b/src/Processor/DataProcessorInterface.php
@@ -7,21 +7,19 @@
/**
* Data processor takes an iterator with source items and produces an iterator with processed items.
*
- * @template TKey as array-key
- * @template TValue as mixed
+ * @template TKey of array-key
+ * @template TValue of mixed
*/
interface DataProcessorInterface
{
/**
* Apply some processing to source items and return results.
*
- * @param iterable $items Source items iterator.
- * @psalm-param iterable $items
+ * @param iterable $items Source items iterator.
*
* @throws DataProcessorException If there is an error while processing items.
*
- * @return iterable Processed items iterator.
- * @psalm-return iterable
+ * @return iterable Processed items iterator.
*/
public function process(iterable $items): iterable;
}
diff --git a/src/Reader/CountableDataInterface.php b/src/Reader/CountableDataInterface.php
index 605d760..d642946 100644
--- a/src/Reader/CountableDataInterface.php
+++ b/src/Reader/CountableDataInterface.php
@@ -12,9 +12,7 @@
interface CountableDataInterface extends Countable
{
/**
- * @return int Number of items in the data.
- *
- * @psalm-return non-negative-int
+ * @return non-negative-int Number of items in the data.
*/
public function count(): int;
}
diff --git a/src/Reader/DataReaderException.php b/src/Reader/DataReaderException.php
index d12a827..83b2ffc 100644
--- a/src/Reader/DataReaderException.php
+++ b/src/Reader/DataReaderException.php
@@ -10,7 +10,5 @@
* Exception occurred during reading data.
*
* @see DataReaderInterface
- *
- * @psalm-suppress ClassMustBeFinal We assume that the class may be extended in userland.
*/
class DataReaderException extends RuntimeException {}
diff --git a/src/Reader/DataReaderInterface.php b/src/Reader/DataReaderInterface.php
index 8449af8..ddc91a6 100644
--- a/src/Reader/DataReaderInterface.php
+++ b/src/Reader/DataReaderInterface.php
@@ -16,8 +16,8 @@
* - Filter
* - Iterate with foreach
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @extends LimitableDataInterface
* @extends OffsetableDataInterface
diff --git a/src/Reader/Filter/In.php b/src/Reader/Filter/In.php
index c7755c5..7541f94 100644
--- a/src/Reader/Filter/In.php
+++ b/src/Reader/Filter/In.php
@@ -28,6 +28,9 @@ public function __construct(
$this->assertValues($values);
}
+ /**
+ * @param bool[]|float[]|int[]|string[]|Stringable[] $values
+ */
private function assertValues(array $values): void
{
foreach ($values as $value) {
diff --git a/src/Reader/FilterableDataInterface.php b/src/Reader/FilterableDataInterface.php
index 3fdc1f3..f8d6885 100644
--- a/src/Reader/FilterableDataInterface.php
+++ b/src/Reader/FilterableDataInterface.php
@@ -15,8 +15,8 @@
*
* For performance reasons, prefer filtering as many items as possible in the first step.
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @extends ReadableDataInterface
*/
diff --git a/src/Reader/Iterable/Context.php b/src/Reader/Iterable/Context.php
index 851b399..ee1f926 100644
--- a/src/Reader/Iterable/Context.php
+++ b/src/Reader/Iterable/Context.php
@@ -14,23 +14,35 @@ final class Context
{
public function __construct(
/**
- * @psalm-var array
+ * @var array>
*/
public readonly array $iterableFilterHandlers,
private readonly ValueReaderInterface $valueReader,
) {}
/**
- * @psalm-param class-string $class
+ * @param class-string $class
+ *
+ * @return IterableFilterHandlerInterface
*/
public function getFilterHandler(string $class): IterableFilterHandlerInterface
{
+ /**
+ * @phpstan-ignore return.type (Each handler is registered only for the filter its `getFilterClass()` returns,
+ * so a handler parameterized with its concrete filter type is safe to use where
+ * `IterableFilterHandlerInterface` is expected.)
+ */
return $this->iterableFilterHandlers[$class]
?? throw new LogicException(
sprintf('Filter "%s" is not supported.', $class),
);
}
+ /**
+ * Read a value from an item by the field name.
+ *
+ * @param array|object $item Item to read value from.
+ */
public function readValue(array|object $item, string $field): mixed
{
return $this->valueReader->read($item, $field);
diff --git a/src/Reader/Iterable/FilterHandler/AllHandler.php b/src/Reader/Iterable/FilterHandler/AllHandler.php
index b9f1527..453b8ec 100644
--- a/src/Reader/Iterable/FilterHandler/AllHandler.php
+++ b/src/Reader/Iterable/FilterHandler/AllHandler.php
@@ -12,6 +12,8 @@
/**
* Handles the {@see All} filter for iterable data readers.
* Always matches all items, effectively disabling filtering.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class AllHandler implements IterableFilterHandlerInterface
{
diff --git a/src/Reader/Iterable/FilterHandler/AndXHandler.php b/src/Reader/Iterable/FilterHandler/AndXHandler.php
index 444f070..f0a0979 100644
--- a/src/Reader/Iterable/FilterHandler/AndXHandler.php
+++ b/src/Reader/Iterable/FilterHandler/AndXHandler.php
@@ -12,6 +12,8 @@
/**
* `AndX` iterable filter handler allows combining multiple sub-filters.
* The filter matches only if all the sub-filters match.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class AndXHandler implements IterableFilterHandlerInterface
{
@@ -22,8 +24,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var AndX $filter */
-
foreach ($filter->filters as $subFilter) {
$filterHandler = $context->getFilterHandler($subFilter::class);
if (!$filterHandler->match($item, $subFilter, $context)) {
diff --git a/src/Reader/Iterable/FilterHandler/BetweenHandler.php b/src/Reader/Iterable/FilterHandler/BetweenHandler.php
index a83cadc..80767af 100644
--- a/src/Reader/Iterable/FilterHandler/BetweenHandler.php
+++ b/src/Reader/Iterable/FilterHandler/BetweenHandler.php
@@ -12,6 +12,8 @@
/**
* `Between` iterable filter handler checks that the item's field value
* is between minimal and maximal values.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class BetweenHandler implements IterableFilterHandlerInterface
{
@@ -22,8 +24,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var Between $filter */
-
$value = $context->readValue($item, $filter->field);
$min = $filter->minValue;
$max = $filter->maxValue;
diff --git a/src/Reader/Iterable/FilterHandler/EqualsHandler.php b/src/Reader/Iterable/FilterHandler/EqualsHandler.php
index 0e4b6cf..199ab1f 100644
--- a/src/Reader/Iterable/FilterHandler/EqualsHandler.php
+++ b/src/Reader/Iterable/FilterHandler/EqualsHandler.php
@@ -11,6 +11,8 @@
/**
* `Equals` iterable filter handler checks that the item's field value matches the given value.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class EqualsHandler implements IterableFilterHandlerInterface
{
@@ -21,8 +23,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var Equals $filter */
-
$itemValue = $context->readValue($item, $filter->field);
$argumentValue = $filter->value;
diff --git a/src/Reader/Iterable/FilterHandler/EqualsNullHandler.php b/src/Reader/Iterable/FilterHandler/EqualsNullHandler.php
index 6eae9ad..c1df2ff 100644
--- a/src/Reader/Iterable/FilterHandler/EqualsNullHandler.php
+++ b/src/Reader/Iterable/FilterHandler/EqualsNullHandler.php
@@ -11,6 +11,8 @@
/**
* `EqualsNull` iterable filter handler checks that the item's field value is null.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class EqualsNullHandler implements IterableFilterHandlerInterface
{
@@ -21,8 +23,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var EqualsNull $filter */
-
return $context->readValue($item, $filter->field) === null;
}
}
diff --git a/src/Reader/Iterable/FilterHandler/GreaterThanHandler.php b/src/Reader/Iterable/FilterHandler/GreaterThanHandler.php
index 77d5342..16dc062 100644
--- a/src/Reader/Iterable/FilterHandler/GreaterThanHandler.php
+++ b/src/Reader/Iterable/FilterHandler/GreaterThanHandler.php
@@ -11,6 +11,8 @@
/**
* `GreaterThan` iterable filter handler checks that the item's field value is greater than the given value.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class GreaterThanHandler implements IterableFilterHandlerInterface
{
@@ -21,8 +23,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var GreaterThan $filter */
-
$itemValue = $context->readValue($item, $filter->field);
$argumentValue = $filter->value;
diff --git a/src/Reader/Iterable/FilterHandler/GreaterThanOrEqualHandler.php b/src/Reader/Iterable/FilterHandler/GreaterThanOrEqualHandler.php
index ea61ee3..561b48c 100644
--- a/src/Reader/Iterable/FilterHandler/GreaterThanOrEqualHandler.php
+++ b/src/Reader/Iterable/FilterHandler/GreaterThanOrEqualHandler.php
@@ -12,6 +12,8 @@
/**
* `GreaterThanOrEqual` iterable filter handler checks that the item's field value
* is greater than or equal to the given value.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class GreaterThanOrEqualHandler implements IterableFilterHandlerInterface
{
@@ -22,8 +24,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var GreaterThanOrEqual $filter */
-
$itemValue = $context->readValue($item, $filter->field);
$argumentValue = $filter->value;
diff --git a/src/Reader/Iterable/FilterHandler/InHandler.php b/src/Reader/Iterable/FilterHandler/InHandler.php
index fe12f17..c9f3342 100644
--- a/src/Reader/Iterable/FilterHandler/InHandler.php
+++ b/src/Reader/Iterable/FilterHandler/InHandler.php
@@ -13,6 +13,8 @@
/**
* `In` iterable filter handler ensures that the field value matches one of the value provided.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class InHandler implements IterableFilterHandlerInterface
{
@@ -23,8 +25,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var In $filter */
-
$itemValue = $context->readValue($item, $filter->field);
$argumentValue = $filter->values;
diff --git a/src/Reader/Iterable/FilterHandler/LessThanHandler.php b/src/Reader/Iterable/FilterHandler/LessThanHandler.php
index beb8207..5c531a0 100644
--- a/src/Reader/Iterable/FilterHandler/LessThanHandler.php
+++ b/src/Reader/Iterable/FilterHandler/LessThanHandler.php
@@ -11,6 +11,8 @@
/**
* `LessThan` iterable filter handler checks that the item's field value is less than the given value.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class LessThanHandler implements IterableFilterHandlerInterface
{
@@ -21,8 +23,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var LessThan $filter */
-
$itemValue = $context->readValue($item, $filter->field);
$argumentValue = $filter->value;
diff --git a/src/Reader/Iterable/FilterHandler/LessThanOrEqualHandler.php b/src/Reader/Iterable/FilterHandler/LessThanOrEqualHandler.php
index 1a16734..dd0cdb1 100644
--- a/src/Reader/Iterable/FilterHandler/LessThanOrEqualHandler.php
+++ b/src/Reader/Iterable/FilterHandler/LessThanOrEqualHandler.php
@@ -12,6 +12,8 @@
/**
* `LessThanOrEqual` iterable filter handler checks that the item's field value
* is less than or equal to the given value.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class LessThanOrEqualHandler implements IterableFilterHandlerInterface
{
@@ -22,8 +24,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var LessThanOrEqual $filter */
-
$itemValue = $context->readValue($item, $filter->field);
$argumentValue = $filter->value;
diff --git a/src/Reader/Iterable/FilterHandler/LikeHandler.php b/src/Reader/Iterable/FilterHandler/LikeHandler.php
index d70e009..937f8a8 100644
--- a/src/Reader/Iterable/FilterHandler/LikeHandler.php
+++ b/src/Reader/Iterable/FilterHandler/LikeHandler.php
@@ -14,6 +14,8 @@
/**
* `Like` iterable filter handler ensures that the field value is like-match to a given value (case-sensitive).
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class LikeHandler implements IterableFilterHandlerInterface
{
@@ -24,8 +26,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var Like $filter */
-
$itemValue = $context->readValue($item, $filter->field);
if (!is_string($itemValue)) {
return false;
diff --git a/src/Reader/Iterable/FilterHandler/NoneHandler.php b/src/Reader/Iterable/FilterHandler/NoneHandler.php
index f11336a..97f54e1 100644
--- a/src/Reader/Iterable/FilterHandler/NoneHandler.php
+++ b/src/Reader/Iterable/FilterHandler/NoneHandler.php
@@ -12,6 +12,8 @@
/**
* Handles the {@see None} filter for iterable data readers.
* Never matches any items, effectively excluding all data.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class NoneHandler implements IterableFilterHandlerInterface
{
diff --git a/src/Reader/Iterable/FilterHandler/NotHandler.php b/src/Reader/Iterable/FilterHandler/NotHandler.php
index abfebab..56f3730 100644
--- a/src/Reader/Iterable/FilterHandler/NotHandler.php
+++ b/src/Reader/Iterable/FilterHandler/NotHandler.php
@@ -11,6 +11,8 @@
/**
* `Not` iterable filter handler negates another filter.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class NotHandler implements IterableFilterHandlerInterface
{
@@ -21,8 +23,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var Not $filter */
-
$subFilter = $filter->filter;
$filterHandler = $context->getFilterHandler($subFilter::class);
diff --git a/src/Reader/Iterable/FilterHandler/OrXHandler.php b/src/Reader/Iterable/FilterHandler/OrXHandler.php
index c03b28b..3196aa0 100644
--- a/src/Reader/Iterable/FilterHandler/OrXHandler.php
+++ b/src/Reader/Iterable/FilterHandler/OrXHandler.php
@@ -12,6 +12,8 @@
/**
* `OrX` iterable filter handler allows combining multiple sub-filters.
* The filter matches if any of the sub-filters match.
+ *
+ * @implements IterableFilterHandlerInterface
*/
final class OrXHandler implements IterableFilterHandlerInterface
{
@@ -22,8 +24,6 @@ public function getFilterClass(): string
public function match(object|array $item, FilterInterface $filter, Context $context): bool
{
- /** @var OrX $filter */
-
foreach ($filter->filters as $subFilter) {
$filterHandler = $context->getFilterHandler($subFilter::class);
if ($filterHandler->match($item, $subFilter, $context)) {
diff --git a/src/Reader/Iterable/IterableDataReader.php b/src/Reader/Iterable/IterableDataReader.php
index 064a9aa..71a80e5 100644
--- a/src/Reader/Iterable/IterableDataReader.php
+++ b/src/Reader/Iterable/IterableDataReader.php
@@ -44,8 +44,8 @@
* - Form a filter criteria with {@see FilterInterface}
* - Post-filter items with {@see IterableFilterHandlerInterface}
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @implements DataReaderInterface
*/
@@ -55,7 +55,7 @@ final class IterableDataReader implements DataReaderInterface
private FilterInterface $filter;
/**
- * @psalm-var non-negative-int|null
+ * @var non-negative-int|null
*/
private ?int $limit = null;
private int $offset = 0;
@@ -63,9 +63,8 @@ final class IterableDataReader implements DataReaderInterface
private Context $context;
/**
- * @param iterable $data Data to iterate.
- * @param IterableFilterHandlerInterface[] $extraFilterHandlers
- * @psalm-param iterable $data
+ * @param iterable $data Data to iterate.
+ * @param IterableFilterHandlerInterface[] $extraFilterHandlers
*/
public function __construct(
private readonly iterable $data,
@@ -101,7 +100,7 @@ public function withFilter(FilterInterface $filter): static
}
/**
- * @psalm-return $this
+ * @return static New instance.
*/
public function withLimit(?int $limit): static
{
@@ -115,7 +114,7 @@ public function withLimit(?int $limit): static
}
/**
- * @psalm-return $this
+ * @return static New instance.
*/
public function withOffset(int $offset): static
{
@@ -125,7 +124,7 @@ public function withOffset(int $offset): static
}
/**
- * @psalm-return $this
+ * @return static New instance.
*/
public function withSort(?Sort $sort): static
{
@@ -135,7 +134,7 @@ public function withSort(?Sort $sort): static
}
/**
- * @psalm-return Generator
+ * @return Generator
*/
public function getIterator(): Generator
{
@@ -153,7 +152,7 @@ public function count(): int
}
/**
- * @psalm-return array
+ * @return array
*/
public function read(): array
{
@@ -189,7 +188,7 @@ public function getOffset(): int
}
/**
- * @psalm-return array
+ * @return array
*/
private function internalRead(bool $useLimitAndOffset): array
{
@@ -222,7 +221,7 @@ private function internalRead(bool $useLimitAndOffset): array
/**
* Return whether an item matches iterable filter.
*
- * @param array|object $item Item to check.
+ * @param array|object $item Item to check.
* @param FilterInterface $filter Filter.
*
* @return bool Whether an item matches iterable filter.
@@ -236,13 +235,10 @@ private function matchFilter(array|object $item, FilterInterface $filter): bool
/**
* Sorts data items according to the given sort definition.
*
- * @param iterable $items The items to be sorted.
+ * @param iterable $items The items to be sorted.
* @param Sort $sort The sort definition.
*
- * @return array The sorted items.
- *
- * @psalm-param iterable $items
- * @psalm-return iterable
+ * @return iterable The sorted items.
*/
private function sortItems(iterable $items, Sort $sort): iterable
{
@@ -274,10 +270,9 @@ static function (array|object $itemA, array|object $itemB) use ($criteria) {
}
/**
- * @param IterableFilterHandlerInterface[] $filterHandlers
+ * @param IterableFilterHandlerInterface[] $filterHandlers
*
- * @return IterableFilterHandlerInterface[]
- * @psalm-return array
+ * @return array>
*/
private function prepareFilterHandlers(array $filterHandlers): array
{
@@ -291,12 +286,9 @@ private function prepareFilterHandlers(array $filterHandlers): array
/**
* Convert iterable to array.
*
- * @param iterable $iterable Iterable to convert.
- *
- * @psalm-param iterable $iterable
+ * @param iterable $iterable Iterable to convert.
*
- * @return array Resulting array.
- * @psalm-return array
+ * @return array Resulting array.
*/
private function iterableToArray(iterable $iterable): array
{
diff --git a/src/Reader/Iterable/IterableFilterHandlerInterface.php b/src/Reader/Iterable/IterableFilterHandlerInterface.php
index f28ee10..6863fff 100644
--- a/src/Reader/Iterable/IterableFilterHandlerInterface.php
+++ b/src/Reader/Iterable/IterableFilterHandlerInterface.php
@@ -9,6 +9,8 @@
/**
* Iterable filter handler checks whether an item matches criteria defined
* in the filter with the same operator.
+ *
+ * @template TFilter of FilterInterface
*/
interface IterableFilterHandlerInterface
{
@@ -16,8 +18,8 @@ interface IterableFilterHandlerInterface
* Check whether an item matches iterable filter handlers
* for the filters with matching operator active.
*
- * @param array|object $item Item to check.
- * @param FilterInterface $filter Matched filter.
+ * @param array|object $item Item to check.
+ * @param TFilter $filter Matched filter.
*
* @return bool Whether item matches the filter.
*/
@@ -28,9 +30,7 @@ public function match(array|object $item, FilterInterface $filter, Context $cont
*
* If the filter is active, a corresponding handler will be used during matching.
*
- * @return string The filter class name.
- *
- * @psalm-return class-string
+ * @return class-string The filter class name.
*/
public function getFilterClass(): string;
}
diff --git a/src/Reader/Iterable/ValueReader/ValueReaderInterface.php b/src/Reader/Iterable/ValueReader/ValueReaderInterface.php
index 56d644f..efdad8d 100644
--- a/src/Reader/Iterable/ValueReader/ValueReaderInterface.php
+++ b/src/Reader/Iterable/ValueReader/ValueReaderInterface.php
@@ -6,5 +6,10 @@
interface ValueReaderInterface
{
+ /**
+ * Read a value from an item by the field name.
+ *
+ * @param array|object $item Item to read value from.
+ */
public function read(object|array $item, string $field): mixed;
}
diff --git a/src/Reader/LimitableDataInterface.php b/src/Reader/LimitableDataInterface.php
index dde7edb..f595de9 100644
--- a/src/Reader/LimitableDataInterface.php
+++ b/src/Reader/LimitableDataInterface.php
@@ -9,8 +9,8 @@
/**
* Data that could be limited.
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @extends ReadableDataInterface
*/
@@ -19,23 +19,18 @@ interface LimitableDataInterface extends ReadableDataInterface
/**
* Get a new instance with the limit set.
*
- * @param int|null $limit Limit. `null` means no limit.
+ * @param non-negative-int|null $limit Limit. `null` means no limit.
*
* @throws InvalidArgumentException If the limit is less than zero.
*
* @return static New instance.
- *
- * @psalm-param non-negative-int|null $limit
- * @psalm-return $this
*/
public function withLimit(?int $limit): static;
/**
* Get current limit.
*
- * @return int|null Limit. `null` means no limit.
- *
- * @psalm-return non-negative-int|null
+ * @return non-negative-int|null Limit. `null` means no limit.
*/
public function getLimit(): ?int;
}
diff --git a/src/Reader/OffsetableDataInterface.php b/src/Reader/OffsetableDataInterface.php
index cfd5b58..9c1dd79 100644
--- a/src/Reader/OffsetableDataInterface.php
+++ b/src/Reader/OffsetableDataInterface.php
@@ -7,8 +7,8 @@
/**
* Data that could be read from Nth item by skipping items from the beginning.
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @extends ReadableDataInterface
*/
@@ -20,7 +20,6 @@ interface OffsetableDataInterface extends ReadableDataInterface
* @param int $offset Offset.
*
* @return $this New instance.
- * @psalm-return $this
*/
public function withOffset(int $offset): static;
diff --git a/src/Reader/OrderHelper.php b/src/Reader/OrderHelper.php
index d329c69..068a9ae 100644
--- a/src/Reader/OrderHelper.php
+++ b/src/Reader/OrderHelper.php
@@ -12,7 +12,7 @@
use const PREG_SPLIT_NO_EMPTY;
/**
- * @psalm-import-type TOrder from Sort
+ * @phpstan-import-type TOrder from Sort
*/
final class OrderHelper
{
@@ -25,16 +25,14 @@ final class OrderHelper
*
* @param string $orderString Logical fields order as comma-separated string.
*
- * @return array Logical fields order as an array.
- *
- * @psalm-return TOrder
+ * @return TOrder Logical fields order as an array.
*/
public static function stringToArray(string $orderString): array
{
$order = [];
/**
- * @var string[] $parts We use correct regexp here, so `preg_split` never returns false.
+ * @var list $parts We use correct regexp here, so `preg_split` never returns false.
*/
$parts = preg_split('/\s*,\s*/', trim($orderString), -1, PREG_SPLIT_NO_EMPTY);
@@ -56,7 +54,7 @@ public static function stringToArray(string $orderString): array
* If the name is prefixed with `-`, field order is descending.
* Otherwise, the order is ascending.
*
- * @param array $order Logical fields order as an array.
+ * @param TOrder $order Logical fields order as an array.
*
* @return string An order string.
*/
diff --git a/src/Reader/ReadableDataInterface.php b/src/Reader/ReadableDataInterface.php
index 3d83f31..0c19463 100644
--- a/src/Reader/ReadableDataInterface.php
+++ b/src/Reader/ReadableDataInterface.php
@@ -7,16 +7,15 @@
/**
* Readable data is a data set that could be read up by getting an iterator or reading one item from a set.
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*/
interface ReadableDataInterface
{
/**
* Get iterable for the data set.
*
- * @return iterable Iterable for the data. Note that keys could be anything so you shouldn't rely on these.
- * @psalm-return iterable
+ * @return iterable Iterable for the data. Note that keys could be anything so you shouldn't rely on these.
*/
public function read(): iterable;
@@ -24,8 +23,7 @@ public function read(): iterable;
* Get one item from the data set. Which item is returned is up to implementation.
* Note that invoking this method doesn't impact the data set or its pointer.
*
- * @return array|object|null An item or null if there is none.
- * @psalm-return TValue|null
+ * @return TValue|null An item or null if there is none.
*/
public function readOne(): array|object|null;
}
diff --git a/src/Reader/Sort.php b/src/Reader/Sort.php
index 7a76a96..23113ca 100644
--- a/src/Reader/Sort.php
+++ b/src/Reader/Sort.php
@@ -40,23 +40,23 @@
* against the fields your application allows before setting the order. Unchecked field names can lead to SQL injection
* when used with a database-backed reader.
*
- * @psalm-type TOrder = array
- * @psalm-type TSortFieldItem = array
- * @psalm-type TConfigItem = array{asc: TSortFieldItem, desc: TSortFieldItem, default: "asc"|"desc"}
- * @psalm-type TConfig = array
- * @psalm-type TUserConfigItem = array{
+ * @phpstan-type TOrder = array
+ * @phpstan-type TSortFieldItem = array
+ * @phpstan-type TConfigItem = array{asc: TSortFieldItem, desc: TSortFieldItem, default: "asc"|"desc"}
+ * @phpstan-type TConfig = array
+ * @phpstan-type TUserConfigItem = array{
* asc?: int|"asc"|"desc"|array,
* desc?: int|"asc"|"desc"|array,
* default?: "asc"|"desc"
* }
- * @psalm-type TUserConfig = array|array
+ * @phpstan-type TUserConfig = array|array
*/
final class Sort
{
/**
* Logical fields config.
*
- * @psalm-var TConfig
+ * @var TConfig
*/
private array $config;
@@ -66,14 +66,12 @@ final class Sort
private bool $withDefaultSorting = true;
/**
- * @var array Logical fields to order by in form of `[name => direction]`.
- * @psalm-var TOrder
+ * @var TOrder Logical fields to order by in form of `[name => direction]`.
*/
private array $currentOrder = [];
/**
- * @param array $config Logical fields config.
- * @psalm-param TUserConfig $config
+ * @param TUserConfig $config Logical fields config.
*
* @param bool $ignoreExtraFields Whether to ignore logical fields not present in the config when forming criteria.
*/
@@ -94,7 +92,7 @@ private function __construct(private bool $ignoreExtraFields, array $config)
$fieldName = $fieldConfig;
$fieldConfig = [];
} else {
- /** @psalm-var TUserConfigItem $fieldConfig */
+ /** @var TUserConfigItem $fieldConfig */
foreach ($fieldConfig as $key => &$criteria) {
// 'default' => 'asc' or 'desc'
if ($key === 'default') {
@@ -128,7 +126,7 @@ private function __construct(private bool $ignoreExtraFields, array $config)
);
}
- /** @psalm-var TConfig $normalizedConfig */
+ /** @var TConfig $normalizedConfig */
$this->config = $normalizedConfig;
}
@@ -137,8 +135,7 @@ private function __construct(private bool $ignoreExtraFields, array $config)
*
* Recommended by default, especially for user input. Define the allowed logical fields in application code.
*
- * @param array $config Logical fields config.
- * @psalm-param TUserConfig $config
+ * @param TUserConfig $config Logical fields config.
*
* ```php
* [
@@ -183,8 +180,7 @@ public static function only(array $config): self
* {@see withOrderString()}, validate field names against the fields your application allows. Unchecked field names
* can lead to SQL injection when used with a database-backed reader. Prefer {@see only()} for user input.
*
- * @param array $config Logical fields config.
- * @psalm-param TUserConfig $config
+ * @param TUserConfig $config Logical fields config.
*
* ```php
* [
@@ -243,8 +239,7 @@ public function withOrderString(string $orderString): self
/**
* Return a new instance with a logical field order set.
*
- * @param array $order A map with logical field names to order by as keys, direction as values.
- * @psalm-param TOrder $order
+ * @param TOrder $order A map with logical field names to order by as keys, direction as values.
*
* @return self New instance.
*/
@@ -270,8 +265,7 @@ public function withoutDefaultSorting(): self
/**
* Get current logical fields order.
*
- * @return array Logical fields order.
- * @psalm-return TOrder
+ * @return TOrder Logical fields order.
*/
public function getOrder(): array
{
@@ -296,8 +290,7 @@ public function getOrderAsString(): string
* Get a sorting criteria to be applied to {@see SortableDataInterface}
* when getting the data that is a list of real fields along with their order directions.
*
- * @return array Sorting criteria.
- * @psalm-return array
+ * @return array Sorting criteria.
*/
public function getCriteria(): array
{
diff --git a/src/Reader/SortableDataInterface.php b/src/Reader/SortableDataInterface.php
index 2d69d01..92dcc30 100644
--- a/src/Reader/SortableDataInterface.php
+++ b/src/Reader/SortableDataInterface.php
@@ -8,8 +8,8 @@
* A data set that could be sorted.
* The sorting set may be used by a data reader that supports sorting.
*
- * @template TKey as array-key
- * @template TValue as array|object
+ * @template TKey of array-key
+ * @template TValue of array|object
*
* @extends ReadableDataInterface
*/
@@ -21,7 +21,6 @@ interface SortableDataInterface extends ReadableDataInterface
* @param Sort|null $sort Sorting criteria or null for no sorting.
*
* @return static New instance.
- * @psalm-return $this
*/
public function withSort(?Sort $sort): static;
diff --git a/src/Writer/DataWriterException.php b/src/Writer/DataWriterException.php
index 485ad31..2e4f968 100644
--- a/src/Writer/DataWriterException.php
+++ b/src/Writer/DataWriterException.php
@@ -10,7 +10,5 @@
* Exception occurred during writing or deleting data.
*
* @see DataWriterInterface
- *
- * @psalm-suppress ClassMustBeFinal We assume that the class may be extended in userland.
*/
class DataWriterException extends RuntimeException {}
diff --git a/src/Writer/DeletableInterface.php b/src/Writer/DeletableInterface.php
index e50e63a..6bd44a3 100644
--- a/src/Writer/DeletableInterface.php
+++ b/src/Writer/DeletableInterface.php
@@ -12,7 +12,7 @@ interface DeletableInterface
/**
* Delete items specified.
*
- * @param iterable $items Items to delete.
+ * @param iterable|object> $items Items to delete.
*
* @throws DataWriterException If there is an error deleting items.
*/
diff --git a/src/Writer/WriteableInterface.php b/src/Writer/WriteableInterface.php
index 5698564..2ae9dff 100644
--- a/src/Writer/WriteableInterface.php
+++ b/src/Writer/WriteableInterface.php
@@ -12,7 +12,7 @@ interface WriteableInterface
/**
* Write items specified.
*
- * @param iterable $items Items to write.
+ * @param iterable|object> $items Items to write.
*
* @throws DataWriterException If there is an error while writing items.
*/
diff --git a/tests/Paginator/PageTokenAssertTrait.php b/tests/Paginator/PageTokenAssertTrait.php
index c34e741..cc6034a 100644
--- a/tests/Paginator/PageTokenAssertTrait.php
+++ b/tests/Paginator/PageTokenAssertTrait.php
@@ -6,12 +6,8 @@
use PHPUnit\Framework\Constraint\IsIdentical;
use PHPUnit\Framework\Constraint\IsInstanceOf;
-use PHPUnit\Framework\TestCase;
use Yiisoft\Data\Paginator\PageToken;
-/**
- * @psalm-require-extends TestCase
- */
trait PageTokenAssertTrait
{
public function assertPageToken(
diff --git a/tests/Support/StubOffsetData.php b/tests/Support/StubOffsetData.php
index 0dcbc36..ba6523d 100644
--- a/tests/Support/StubOffsetData.php
+++ b/tests/Support/StubOffsetData.php
@@ -16,8 +16,7 @@ final class StubOffsetData implements
LimitableDataInterface
{
/**
- * @var int|null
- * @psalm-var non-negative-int
+ * @var non-negative-int|null
*/
private ?int $limit = null;
diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json
deleted file mode 100644
index b048ebf..0000000
--- a/tools/psalm/composer.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "require-dev": {
- "vimeo/psalm": "^6.14.1"
- }
-}