Skip to content

Commit

Permalink
ThrowsPhpDocRule: fixed double creation of virtual node when a trait …
Browse files Browse the repository at this point in the history
…is used (#44)
  • Loading branch information
pepakriz authored Dec 2, 2018
1 parent a1cb24d commit 9d41e60
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Rules/ThrowsPhpDocRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
class ThrowsPhpDocRule implements Rule
{

private const ATTRIBUTE_HAS_CLASS_METHOD_END = '__HAS_CLASS_METHOD_END__';
private const ATTRIBUTE_HAS_TRY_CATCH_END = '__HAS_TRY_CATCH_END__';

/**
* @var CheckedExceptionService
*/
Expand Down Expand Up @@ -156,7 +159,10 @@ private function processTryCatch(TryCatch $node, Scope $scope): array

$this->throwsScope->enterToTryCatch($node);

$node->stmts[] = new TryCatchTryEnd($node);
if (!$node->hasAttribute(self::ATTRIBUTE_HAS_TRY_CATCH_END)) {
$node->setAttribute(self::ATTRIBUTE_HAS_TRY_CATCH_END, true);
$node->stmts[] = new TryCatchTryEnd($node);
}

return [];
}
Expand Down Expand Up @@ -341,7 +347,10 @@ private function processClassMethod(ClassMethod $node, Scope $scope): array
$this->throwsScope->enterToThrowsAnnotationBlock($methodReflection->getThrowType());
}

$node->stmts[] = new ClassMethodEnd($node);
if (!$node->hasAttribute(self::ATTRIBUTE_HAS_CLASS_METHOD_END)) {
$node->setAttribute(self::ATTRIBUTE_HAS_CLASS_METHOD_END, true);
$node->stmts[] = new ClassMethodEnd($node);
}

return [];
}
Expand Down

0 comments on commit 9d41e60

Please sign in to comment.