Skip to content

Commit

Permalink
"Unable to resolve template type" has to check against explicit Never…
Browse files Browse the repository at this point in the history
…Type only
  • Loading branch information
ondrejmirtes committed Jan 24, 2021
1 parent e5bac6e commit ba4bc4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Rules/FunctionCallParametersCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,13 @@ static function (Type $type): bool {
});

foreach ($parametersAcceptor->getResolvedTemplateTypeMap()->getTypes() as $name => $type) {
if (!($type instanceof ErrorType) && !($type instanceof NeverType)) {
if (
!($type instanceof ErrorType)
&& (
!$type instanceof NeverType
|| $type->isExplicit()
)
) {
continue;
}

Expand Down
17 changes: 17 additions & 0 deletions tests/PHPStan/Rules/Functions/data/call-generic-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,20 @@ function g($a) {}
function testg(): void {
g(new \DateTimeImmutable());
}

/**
* @template TReturnType
* @param (callable(): TReturnType) $callback
* @return TReturnType
*/
function scope(callable $callback) {
return $callback();
}

function (): void {
scope(
function (): void {
throw new \Exception();
}
);
};

0 comments on commit ba4bc4f

Please sign in to comment.