Skip to content

Commit

Permalink
Add non-empty-list support
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 9, 2019
1 parent 6a07757 commit 51cfd55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Analyzer\Statements\Expression\AssertionFinder;
use Psalm\Internal\Codebase\CallMap;
use Psalm\Issue\InvalidReturnType;
Expand Down Expand Up @@ -61,8 +62,18 @@ public static function getFunctionReturnType(
}

if (!isset($call_args[1])) {
$inner_type->removeType('null');
$inner_type->removeType('false');
if ($statements_source instanceof StatementsAnalyzer) {
$inner_type = \Psalm\Internal\Type\AssertionReconciler::reconcile(
'!falsy',
clone $inner_type,
'',
$statements_source,
$context->inside_loop,
[],
null,
$statements_source->getSuppressedIssues()
);
}
} elseif (!isset($call_args[2])) {
$function_call_arg = $call_args[1];

Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ abstract class Type
'value-of' => true,
'non-empty-countable' => true,
'list' => true,
'non-empty-list' => true,
];

/**
Expand Down

0 comments on commit 51cfd55

Please sign in to comment.