Conversation
There was a problem hiding this comment.
Pull request overview
This PR corrects the type documentation for isList and isNonEmptyList methods by adding generic type parameters (<T>) to make them properly type-safe. It also adds a missing Throwable import to both the Mixin.php file and the MixinGenerator.php file that generates it.
Changes:
- Added
<T>generic type parameters toisListandisNonEmptyListtype annotations in Assert.php and their mixin variants in Mixin.php - Added missing
Throwableimport to Mixin.php and updated MixinGenerator.php to generate this import
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/Assert.php | Added @template T and updated @psalm-assert and @psalm-return annotations for isList and isNonEmptyList methods to use generic type list<T> and non-empty-list<T> |
| src/Mixin.php | Added Throwable import and updated type annotations for nullOr*, all*, and allNullOr* variants of isList and isNonEmptyList methods with generic type parameters |
| bin/src/MixinGenerator.php | Added Throwable import and updated generator to include Throwable in generated Mixin.php namespace imports |
| CHANGELOG.md | Added version 2.1.3 entry documenting the isList type documentation correction |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @psalm-assert non-empty-list<T>|null $array | ||
| * | ||
| * @return non-empty-list|null | ||
| * @template T | ||
| * @return non-empty-list<T>|null |
There was a problem hiding this comment.
The @template annotation should be placed before @psalm-assert to maintain consistency with other templated methods in this file. For example, see the nullOrIsInstanceOf method (line 1146-1147), allIsInstanceOf method (line 1165-1166), nullOrIsMap method (line 4903-4904), allIsMap method (line 4922-4923), and allNullOrIsMap method (line 4945-4946). The correct order should be: @psalm-pure, @template T, @psalm-assert.
| * @psalm-assert iterable<non-empty-list<T>> $array | ||
| * | ||
| * @return iterable<non-empty-list> | ||
| * @template T | ||
| * @return iterable<non-empty-list<T>> |
There was a problem hiding this comment.
The @template annotation should be placed before @psalm-assert to maintain consistency with other templated methods in this file. For example, see the nullOrIsInstanceOf method (line 1146-1147), allIsInstanceOf method (line 1165-1166), nullOrIsMap method (line 4903-4904), allIsMap method (line 4922-4923), and allNullOrIsMap method (line 4945-4946). The correct order should be: @psalm-pure, @template T, @psalm-assert.
| * @psalm-assert iterable<non-empty-list<T>|null> $array | ||
| * | ||
| * @return iterable<non-empty-list|null> | ||
| * @template T | ||
| * @return iterable<non-empty-list<T>|null> |
There was a problem hiding this comment.
The @template annotation should be placed before @psalm-assert to maintain consistency with other templated methods in this file. For example, see the nullOrIsInstanceOf method (line 1146-1147), allIsInstanceOf method (line 1165-1166), nullOrIsMap method (line 4903-4904), allIsMap method (line 4922-4923), and allNullOrIsMap method (line 4945-4946). The correct order should be: @psalm-pure, @template T, @psalm-assert.
| * @psalm-assert list<T> $array | ||
| * | ||
| * @psalm-return list | ||
| * @psalm-return list<T> | ||
| * | ||
| * @template T |
There was a problem hiding this comment.
The @template annotation should be placed at the beginning of the docblock (after @psalm-pure), before @psalm-assert, to maintain consistency with other templated methods in this file. For example, see the isInstanceOf method (line 475), notInstanceOf method (line 503), isAOf method (line 558), isNotA method (line 587), and isMap method (line 2028). The correct order should be: @psalm-pure, @template T, @psalm-assert, @psalm-return.
| * @psalm-assert non-empty-list<T> $array | ||
| * | ||
| * @psalm-return non-empty-list | ||
| * @psalm-return non-empty-list<T> | ||
| * | ||
| * @template T |
There was a problem hiding this comment.
The @template annotation should be placed at the beginning of the docblock (after @psalm-pure), before @psalm-assert, to maintain consistency with other templated methods in this file. For example, see the isInstanceOf method (line 475), notInstanceOf method (line 503), isAOf method (line 558), isNotA method (line 587), and isMap method (line 2028). The correct order should be: @psalm-pure, @template T, @psalm-assert, @psalm-return.
| * @psalm-assert list<T>|null $array | ||
| * | ||
| * @return list|null | ||
| * @template T | ||
| * @return list<T>|null |
There was a problem hiding this comment.
The @template annotation should be placed before @psalm-assert to maintain consistency with other templated methods in this file. For example, see the nullOrIsInstanceOf method (line 1146-1147), allIsInstanceOf method (line 1165-1166), nullOrIsMap method (line 4903-4904), allIsMap method (line 4922-4923), and allNullOrIsMap method (line 4945-4946). The correct order should be: @psalm-pure, @template T, @psalm-assert.
Also adds missing import for
Throwablein Mixin.