1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #1093 - add exception type to list of scanned classes

This commit is contained in:
Matthew Brown 2018-11-25 16:14:50 -05:00
parent d90cff8f10
commit af041abdcb
2 changed files with 42 additions and 0 deletions

View File

@ -1187,6 +1187,8 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
$this->aliases
);
$this->codebase->scanner->queueClassLikeForScanning($exception_fqcln, $this->file_path);
$storage->throws[$exception_fqcln] = true;
}
}

View File

@ -337,6 +337,46 @@ class AnnotationTest extends TestCase
$this->analyzeFile('somefile.php', $context);
}
/**
* @return void
*/
public function testDocumentedThrowInFunctionCallWithoutThrow()
{
Config::getInstance()->check_for_throws_docblock = true;
$this->addFile(
'somefile.php',
'<?php
class Foo
{
/**
* @throws \TypeError
*/
public static function notReallyThrowing(int $a): string
{
if ($a > 0) {
return "";
}
return (string) $a;
}
public function test(): string
{
try {
return self::notReallyThrowing(2);
} catch (\Throwable $E) {
return "";
}
}
}'
);
$context = new Context();
$this->analyzeFile('somefile.php', $context);
}
/**
* @return void
*/