Skip to content

Commit

Permalink
Fix #2636 - allow non-empty-list in assert annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 17, 2020
1 parent f956000 commit adf230e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Psalm/Internal/Visitor/ReflectorVisitor.php
Expand Up @@ -2741,6 +2741,7 @@ private function getAssertionParts(
foreach ($namespaced_type->getAtomicTypes() as $namespaced_type_part) {
if ($namespaced_type_part instanceof Type\Atomic\TAssertionFalsy
|| ($namespaced_type_part instanceof Type\Atomic\TList
&& !$namespaced_type_part instanceof Type\Atomic\TNonEmptyList
&& $namespaced_type_part->type_param->isMixed())
|| ($namespaced_type_part instanceof Type\Atomic\TArray
&& $namespaced_type_part->type_params[0]->isArrayKey()
Expand Down
19 changes: 19 additions & 0 deletions tests/AssertAnnotationTest.php
Expand Up @@ -848,6 +848,25 @@ function foo(A $a) : void {
*/
function validate(array $data): void {}'
],
'nonEmptyList' => [
'<?php
/**
* @psalm-assert non-empty-list $array
*
* @param mixed $array
*/
function isNonEmptyList($array): void {}
/**
* @psalm-param mixed $value
*
* @psalm-return non-empty-list<mixed>
*/
function consume($value): array {
isNonEmptyList($value);
return $value;
}'
],
];
}

Expand Down

0 comments on commit adf230e

Please sign in to comment.