Repository navigation
Conversation
Reviewer's GuideAPIMigrate public data and paginator contracts to PHPStan generic and refined-type annotations, keeping their declared runtime APIs unchanged.
ImplementationUpdate paginator internals for PHPStan annotations and remove the redundant limitability check now that the reader contract guarantees that capability.
Migrate keyset pagination's internal types and assertions to PHPStan and add targeted suppressions for values whose safety follows from runtime control flow.
Add PHPStan-compatible input and item types to iterable filters, readers, value readers, and filter handlers.
ConfigurationSwitch static-analysis CI to PHPStan, add its development dependency and Composer command, and configure the migration's analysis settings.
DocumentationUpdate project-facing static-analysis instructions and changelog, and remove obsolete Psalm badges.
TestsRemove Psalm-specific test-trait requirements that are no longer relevant after the analyzer migration.
Other changesFiles not grouped.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #259 +/- ##
===========================================
Coverage 100.00% 100.00%
+ Complexity 256 255 -1
===========================================
Files 33 33
Lines 647 647
===========================================
Hits 647 647 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/Reader/Iterable/IterableDataReader.php" line_range="68" />
<code_context>
*
- * @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
{
</code_context>
<issue_to_address>
**Custom handlers fail static analysis**
When a PHPStan-checked caller passes a handler parameterized by its concrete filter type, `IterableDataReader::__construct` types `$extraFilterHandlers` as `IterableFilterHandlerInterface<FilterInterface>[]`; because the interface's filter type is invariant, PHPStan rejects the concrete handler and the caller cannot use the extension point without weakening types or suppressing the error.
Adjust the constructor's `$extraFilterHandlers` generic annotation so handlers specialized to concrete filter types are accepted.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/Reader/Iterable/IterableDataReader.php:68
| * @param int $offset Offset. | ||
| * | ||
| * @return $this New instance. | ||
| * @psalm-return $this |
There was a problem hiding this comment.
While removing this Psalm tag, can we also change the @return $this line above to @return static? $this means the method returns the same object, but IterableDataReader::withOffset() returns a clone.
/** @var OffsetableDataInterface<int, array{id: int}> $reader */
$reader = new IterableDataReader([['id' => 1]]);
var_dump($reader === $reader->withOffset(1)); // false| * @param class-string<FilterInterface> $class | ||
| * | ||
| * @return IterableFilterHandlerInterface<FilterInterface> |
There was a problem hiding this comment.
PHPStan accepts getFilterHandler(Equals::class)->match([], new None(), $context), but the call throws a TypeError at runtime. Can we use the filter class to tell PHPStan which filter the returned handler accepts?
| * @param class-string<FilterInterface> $class | |
| * | |
| * @return IterableFilterHandlerInterface<FilterInterface> | |
| * @template TFilter of FilterInterface | |
| * @param class-string<TFilter> $class | |
| * | |
| * @return IterableFilterHandlerInterface<TFilter> |
| * Iterable filter handler checks whether an item matches criteria defined | ||
| * in the filter with the same operator. | ||
| * | ||
| * @template TFilter of FilterInterface |
There was a problem hiding this comment.
PHPStan now reports missingType.generics for existing custom handlers that implement this interface without a type argument. A default lets those handlers keep working and still allows new handlers to specify a filter type.
| * @template TFilter of FilterInterface | |
| * @template TFilter of FilterInterface = FilterInterface |
| * Write items specified. | ||
| * | ||
| * @param iterable $items Items to write. | ||
| * @param iterable<array<mixed>|object> $items Items to write. |
There was a problem hiding this comment.
PHPStan now rejects $writer->write([42]). The previous iterable type allowed scalar items. Can we keep accepting them?
| * @param iterable<array<mixed>|object> $items Items to write. | |
| * @param iterable<mixed> $items Items to write. |
| * Delete items specified. | ||
| * | ||
| * @param iterable $items Items to delete. | ||
| * @param iterable<array<mixed>|object> $items Items to delete. |
There was a problem hiding this comment.
PHPStan now rejects $deleter->delete([42]). The previous iterable type allowed scalar items. Can we keep accepting them?
| * @param iterable<array<mixed>|object> $items Items to delete. | |
| * @param iterable<mixed> $items Items to delete. |
Summary by Sourcery
Replace Psalm with PHPStan as the project's static-analysis tool and align paginator behavior and type documentation with the new analyzer.
Bug Fixes:
Enhancements:
Build:
CI:
Documentation: