mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2720 - allow throwing self
This commit is contained in:
parent
b46f219c51
commit
8f95c5679e
@ -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,
|
||||
|
@ -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();
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user