Add assert is list - #66
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Assert::isList() assertion to complement existing Assert::isArray() behavior, and introduces a PHPStan dynamic return type extension so isList() preserves element type information as list<V> during static analysis.
Changes:
- Added
Assert::isList(mixed $value): arrayruntime assertion usingarray_is_list(). - Added a PHPStan
DynamicStaticMethodReturnTypeExtension+ integration tests to inferlist<V>while preserving value types. - Updated configuration (
extension.neon) and documentation (README.md) to expose/register the new feature.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Assert.php |
Adds Assert::isList() runtime assertion method. |
src/PHPStan/Extension/AssertIsListReturnExtension.php |
Adds PHPStan dynamic return type extension for Assert::isList(). |
extension.neon |
Registers the new PHPStan extension service. |
tests/Unit/AssertTest.php |
Adds unit tests for isList() success and failure modes. |
tests/Integration/PHPStan/AssertIsListExtensionTest.php |
Adds PHPStan type-inference test harness for the new extension. |
tests/Integration/PHPStan/data/AssertIsListAssertions.php |
Provides assertType() cases validating inferred list/value types. |
README.md |
Documents isList in the Assert method list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bram123
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Assert::isListto assert an array is of typelist<mixed>Added phpstan extension to preserve value type information, as this was not possible with phpstan standard docblock notation.
Scenarios:
mixed, out:list<mixed>int[], out:list<int>array<int|string..>, out:list<int|string..>Security advisories
Had to remove PHPUnit 10 + 11 due to:
Root composer.json requires phpunit/phpunit ^10.2 || ^11.0, found phpunit/phpunit[10.2.0, ..., 10.5.63, 11.0.0, ..., 11.5.55] but these were not loaded, because they are affected by security advisories. To ignore the advisories, add ("PKSA-5jz8-6tcw-pbk4") to the audit "ignore" config.