Make `AnnotateThrowablesRector` continue on unhandled node types.

This commit is contained in:
Aerendir 2020-02-15 00:56:09 +01:00
parent fcec6e301e
commit f734a93272
1 changed files with 3 additions and 7 deletions

View File

@ -13,7 +13,6 @@ use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\Type\ObjectType;
use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocTagNode;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\Core\Exception\NotImplementedException;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\CodeSample;
@ -42,7 +41,7 @@ final class AnnotateThrowablesRector extends AbstractRector
return new RectorDefinition(
'Adds @throws DocBlock comments to methods that thrwo \Throwables.', [
new CodeSample(
// code before
// code before
<<<'PHP'
class RootExceptionInMethodWithDocblock
{
@ -129,10 +128,7 @@ PHP
return $this->identifyThrownThrowablesInStaticCall($throw);
}
throw new NotImplementedException(sprintf(
'The \Throwable "%s" is not supported yet. Please, open an issue.',
get_class($throw->expr)
));
return [];
}
private function identifyThrownThrowablesInStaticCall(Throw_ $node): array
@ -144,7 +140,7 @@ PHP
{
$throwClass = $this->buildFQN($node);
if ($throwClass === null) {
throw new ShouldNotHappenException();
return;
}
$docComment = $this->buildThrowsDocComment($throwClass);