Skip to content

Commit aab3c40

Browse files
committed
Get rid of more Stmt\Throw_ instances
1 parent fefed02 commit aab3c40

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/Parser/LastConditionVisitor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ public function enterNode(Node $node): ?Node
6868
return null;
6969
}
7070

71-
if (!$statements[$statementCount - 1] instanceof Node\Stmt\Throw_) {
71+
$lastStatement = $statements[$statementCount - 1];
72+
73+
if (!$lastStatement instanceof Node\Stmt\Expression) {
74+
return null;
75+
}
76+
77+
if (!$lastStatement->expr instanceof Node\Expr\Throw_) {
7278
return null;
7379
}
7480

src/Rules/Exceptions/OverwrittenExitPointByFinallyRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function describeExitPoint(Node\Stmt $stmt): string
5151
return 'return';
5252
}
5353

54-
if ($stmt instanceof Node\Stmt\Throw_) {
54+
if ($stmt instanceof Node\Stmt\Expression && $stmt->expr instanceof Node\Expr\Throw_) {
5555
return 'throw';
5656
}
5757

src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ public function processNode(Node $node, Scope $scope): array
8989
}
9090

9191
if ($node instanceof Node\Stmt\Expression) {
92+
if ($node->expr instanceof Expr\Throw_) {
93+
return $this->processStmt($scope, $varTags, $node->expr);
94+
}
9295
return $this->processExpression($scope, $node->expr, $varTags);
9396
}
9497

95-
if ($node instanceof Node\Stmt\Throw_ || $node instanceof Node\Stmt\Return_) {
98+
if ($node instanceof Node\Stmt\Return_) {
9699
return $this->processStmt($scope, $varTags, $node->expr);
97100
}
98101

0 commit comments

Comments
 (0)