Skip to content

Commit 7608f8f

Browse files
authored
ThrowsPhpDocRule: create virtual node for non-abstract methods only (#79)
1 parent 079fcbb commit 7608f8f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"license": [
55
"MIT"
66
],
7-
"minimum-stability": "dev",
87
"prefer-stable": true,
98
"extra": {
109
"branch-alias": {

src/Rules/ThrowsPhpDocRule.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ private function processFunction(Node\FunctionLike $node, Scope $scope): array
377377
return [];
378378
}
379379

380-
if ($node->stmts === null) {
381-
$node->stmts = [];
382-
}
383-
384380
$classReflection = $scope->getClassReflection();
385381
if ($classReflection === null) {
386382
try {
@@ -394,6 +390,10 @@ private function processFunction(Node\FunctionLike $node, Scope $scope): array
394390
} catch (MissingMethodFromReflectionException $e) {
395391
throw new ShouldNotHappenException();
396392
}
393+
394+
if ($classReflection->getNativeReflection()->getMethod($methodReflection->getName())->isAbstract()) {
395+
return [];
396+
}
397397
}
398398

399399
if ($methodReflection instanceof ThrowableReflection) {
@@ -402,6 +402,9 @@ private function processFunction(Node\FunctionLike $node, Scope $scope): array
402402

403403
if (!$node->hasAttribute(self::ATTRIBUTE_HAS_CLASS_METHOD_END)) {
404404
$node->setAttribute(self::ATTRIBUTE_HAS_CLASS_METHOD_END, true);
405+
if ($node->stmts === null) {
406+
$node->stmts = [];
407+
}
405408
$node->stmts[] = new FunctionEnd($node);
406409
}
407410

0 commit comments

Comments
 (0)