Repository navigation
Conversation
Reviewer's GuideAPIUpdate public generic interfaces and their PHPStan type contracts, including default template types and corrected return and iterable annotations.
ImplementationApply the new analyzer’s generic filter-handler typing and associated annotations across iterable readers, filter handlers, and sorting helpers.
Review paginator implementation changes together, including the redundant sortability check removal and PHPStan-compatible type assertions.
Remove Psalm-specific exception suppressions and update the stub’s type annotation.
ConfigurationReplace Psalm tooling with PHPStan in Composer scripts, CI workflows, and analysis configuration.
DocumentationDocument the analyzer migration and remove the obsolete Psalm and type-coverage badges.
TestsRemove Psalm-only test-trait constraints that are no longer needed after the analyzer migration.
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. |
There was a problem hiding this comment.
In this package an item is always an array or an object (a structure with named fields, see "Concepts" in README). So scalars are not valid items, and this type just makes the writer consistent with the readers.
| * 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. |
There was a problem hiding this comment.
In this package an item is always an array or an object (a structure with named fields, see "Concepts" in README). So scalars are not valid items, and this type just makes the writer consistent with the readers.
…erface` `withOffset()` returns a clone rather than the same object, so `$this` was inaccurate. Aligns the interface with the other `with*()` methods and the native `: static` return type.
PHPStan now infers `IterableFilterHandlerInterface<TFilter>` from the `class-string<TFilter>` argument, so passing a wrong filter to the returned handler is reported at analysis time instead of failing with a `TypeError` at runtime.
PHPStan reports `missingType.generics` for existing custom handlers, readers, paginators, and processors that implement these interfaces without specifying type arguments. Defaulting each template to its upper bound keeps such implementations valid while still allowing new ones to narrow the types.
Summary by Sourcery
Replace Psalm with PHPStan while refining paginator type annotations and removing a redundant sortability check.
Bug Fixes:
Enhancements:
Build:
CI:
Documentation: