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

Fix #2720 - allow throwing self

This commit is contained in:
Brown 2020-01-30 18:00:31 -05:00
parent b46f219c51
commit 8f95c5679e
2 changed files with 19 additions and 0 deletions

View File

@ -632,6 +632,13 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
}
foreach ($storage->throws as $expected_exception => $_) {
if (($expected_exception === 'self'
|| $expected_exception === 'static')
&& $context->self
) {
$expected_exception = $context->self;
}
if (isset($storage->throw_locations[$expected_exception])) {
if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName(
$statements_analyzer,

View File

@ -1071,6 +1071,18 @@ class AnnotationTest extends TestCase
$data = json_decode("{}", false);
consume($data->value ?? "");'
],
'throwSelf' => [
'<?php
class MyException extends \Exception {
/**
* @throws self
*/
public static function create(): void
{
throw new self();
}
}'
],
];
}