Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

## 2.1.3

### Fixed

- Corrected `isList` type documentation

## 2.1.2

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions bin/src/MixinGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use ReflectionType;
use ReflectionUnionType;
use RuntimeException;
use Throwable;
use Webmozart\Assert\Assert;

final class MixinGenerator
Expand Down Expand Up @@ -77,6 +78,7 @@ private function namespace(): string
$namespace = sprintf("namespace %s;\n\n", $assert->getNamespaceName());
$namespace .= sprintf("use %s;\n", ArrayAccess::class);
$namespace .= sprintf("use %s;\n", Countable::class);
$namespace .= sprintf("use %s;\n", Throwable::class);
$namespace .= "\n";

$namespace .= $this->trait($assert);
Expand Down
12 changes: 8 additions & 4 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -1984,9 +1984,11 @@ public static function countBetween(mixed $array, mixed $min, mixed $max, string
/**
* @psalm-pure
*
* @psalm-assert list $array
* @psalm-assert list<T> $array
*
* @psalm-return list
* @psalm-return list<T>
*
* @template T
Comment on lines +1987 to +1991
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
*
* @throws InvalidArgumentException
*/
Expand All @@ -2004,9 +2006,11 @@ public static function isList(mixed $array, string $message = ''): array
/**
* @psalm-pure
*
* @psalm-assert non-empty-list $array
* @psalm-assert non-empty-list<T> $array
*
* @psalm-return non-empty-list
* @psalm-return non-empty-list<T>
*
* @template T
Comment on lines +2009 to +2013
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
*
* @throws InvalidArgumentException
*/
Expand Down
31 changes: 19 additions & 12 deletions src/Mixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use ArrayAccess;
use Countable;
use Throwable;

/**
* This trait provides nullOr*, all* and allNullOr* variants of assertion base methods.
Expand Down Expand Up @@ -4781,9 +4782,10 @@ public static function allNullOrCountBetween(mixed $array, mixed $min, mixed $ma
/**
* @psalm-pure
*
* @psalm-assert list|null $array
* @psalm-assert list<T>|null $array
*
* @return list|null
* @template T
* @return list<T>|null
Comment on lines +4785 to +4788
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
*
* @throws InvalidArgumentException
*/
Expand All @@ -4797,9 +4799,10 @@ public static function nullOrIsList(mixed $array, string $message = ''): mixed
/**
* @psalm-pure
*
* @psalm-assert iterable<list> $array
* @psalm-assert iterable<list<T>> $array
*
* @return iterable<list>
* @template T
* @return iterable<list<T>>
*
* @throws InvalidArgumentException
*/
Expand All @@ -4817,9 +4820,10 @@ public static function allIsList(mixed $array, string $message = ''): mixed
/**
* @psalm-pure
*
* @psalm-assert iterable<list|null> $array
* @psalm-assert iterable<list<T>|null> $array
*
* @return iterable<list|null>
* @template T
* @return iterable<list<T>|null>
*
* @throws InvalidArgumentException
*/
Expand All @@ -4837,9 +4841,10 @@ public static function allNullOrIsList(mixed $array, string $message = ''): mixe
/**
* @psalm-pure
*
* @psalm-assert non-empty-list|null $array
* @psalm-assert non-empty-list<T>|null $array
*
* @return non-empty-list|null
* @template T
* @return non-empty-list<T>|null
Comment on lines +4844 to +4847
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
*
* @throws InvalidArgumentException
*/
Expand All @@ -4853,9 +4858,10 @@ public static function nullOrIsNonEmptyList(mixed $array, string $message = ''):
/**
* @psalm-pure
*
* @psalm-assert iterable<non-empty-list> $array
* @psalm-assert iterable<non-empty-list<T>> $array
*
* @return iterable<non-empty-list>
* @template T
* @return iterable<non-empty-list<T>>
Comment on lines +4861 to +4864
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
*
* @throws InvalidArgumentException
*/
Expand All @@ -4873,9 +4879,10 @@ public static function allIsNonEmptyList(mixed $array, string $message = ''): mi
/**
* @psalm-pure
*
* @psalm-assert iterable<non-empty-list|null> $array
* @psalm-assert iterable<non-empty-list<T>|null> $array
*
* @return iterable<non-empty-list|null>
* @template T
* @return iterable<non-empty-list<T>|null>
Comment on lines +4882 to +4885
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
*
* @throws InvalidArgumentException
*/
Expand Down