Skip to content

Commit b54c8ca

Browse files
authored
PhpDocValueRule: cheapest check first
1 parent c5ca230 commit b54c8ca

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Rules/PhpDoc/IncompatiblePhpDocTypeRule.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ public function getNodeType(): string
4242

4343
public function processNode(Node $node, Scope $scope): array
4444
{
45-
$docComment = $node->getDocComment();
46-
if ($docComment === null) {
47-
return [];
48-
}
49-
5045
if ($node instanceof Node\Stmt\ClassMethod) {
5146
$functionName = $node->name->name;
5247
} elseif ($node instanceof Node\Stmt\Function_) {
@@ -55,6 +50,11 @@ public function processNode(Node $node, Scope $scope): array
5550
return [];
5651
}
5752

53+
$docComment = $node->getDocComment();
54+
if ($docComment === null) {
55+
return [];
56+
}
57+
5858
$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
5959
$scope->getFile(),
6060
$scope->isInClass() ? $scope->getClassReflection()->getName() : null,

src/Rules/PhpDoc/InvalidThrowsPhpDocValueRule.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public function getNodeType(): string
2929

3030
public function processNode(Node $node, Scope $scope): array
3131
{
32+
if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
33+
return []; // is handled by virtual nodes
34+
}
35+
3236
$docComment = $node->getDocComment();
3337
if ($docComment === null) {
3438
return [];
3539
}
3640

37-
if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
38-
return []; // is handled by virtual nodes
39-
}
40-
4141
$functionName = null;
4242
if ($scope->getFunction() !== null) {
4343
$functionName = $scope->getFunction()->getName();

0 commit comments

Comments
 (0)