Skip to content

Commit

Permalink
PhpDocValueRule: cheapest check first
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 3, 2024
1 parent c5ca230 commit b54c8ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/Rules/PhpDoc/IncompatiblePhpDocTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
$docComment = $node->getDocComment();
if ($docComment === null) {
return [];
}

if ($node instanceof Node\Stmt\ClassMethod) {
$functionName = $node->name->name;
} elseif ($node instanceof Node\Stmt\Function_) {
Expand All @@ -55,6 +50,11 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

$docComment = $node->getDocComment();
if ($docComment === null) {
return [];
}

$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
$scope->getFile(),
$scope->isInClass() ? $scope->getClassReflection()->getName() : null,
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/PhpDoc/InvalidThrowsPhpDocValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
return []; // is handled by virtual nodes
}

$docComment = $node->getDocComment();
if ($docComment === null) {
return [];
}

if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
return []; // is handled by virtual nodes
}

$functionName = null;
if ($scope->getFunction() !== null) {
$functionName = $scope->getFunction()->getName();
Expand Down

0 comments on commit b54c8ca

Please sign in to comment.