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:
parent
d90cff8f10
commit
af041abdcb
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user