1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Do not emit issue when callable is called

This commit is contained in:
Matthew Brown 2017-01-01 19:24:15 -05:00
parent 883ca6a5db
commit 30a39a0ee6
2 changed files with 17 additions and 1 deletions

View File

@ -122,7 +122,10 @@ class CallChecker
$stmt->inferredType = $var_type_part->return_type;
}
}
} elseif (!$var_type_part->isMixed() && $var_type_part->value !== 'Closure') {
} elseif (!$var_type_part->isMixed() &&
$var_type_part->value !== 'Closure' &&
!$var_type_part->isCallable()
) {
$var_id = ExpressionChecker::getVarId(
$stmt->name,
$statements_checker->getFQCLN(),

View File

@ -139,6 +139,19 @@ class ClosureTest extends PHPUnit_Framework_TestCase
$this->assertEquals('int', (string) $context->vars_in_scope['$a']);
}
public function testCallable()
{
$stmts = self::$parser->parse('<?php
function foo(Callable $c) : void {
echo (string)$c();
}
');
$file_checker = new FileChecker('somefile.php', $stmts);
$context = new Context('somefile.php');
$file_checker->check(true, true, $context);
}
/**
* @expectedException \Psalm\Exception\CodeException
* @expectedExceptionMessage InvalidFunctionCall