Skip to content

Commit dab4101

Browse files
Do fast check first (#5396)
1 parent c7c7d7a commit dab4101

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Rules/PhpDoc/VarTagTypeRuleHelper.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,9 @@ public function checkExprType(Scope $scope, Node\Expr $expr, Type $varTagType):
9999
$varTagType->describe($verbosity),
100100
$exprNativeType->describe($verbosity),
101101
))->identifier('varTag.nativeType')->build();
102-
} else {
102+
} elseif ($this->checkTypeAgainstPhpDocType || $containsPhpStanType) {
103103
$exprType = $scope->getScopeType($expr);
104-
if (
105-
$this->shouldVarTagTypeBeReported($scope, $expr, $exprType, $varTagType)
106-
&& ($this->checkTypeAgainstPhpDocType || $containsPhpStanType)
107-
) {
104+
if ($this->shouldVarTagTypeBeReported($scope, $expr, $exprType, $varTagType)) {
108105
$verbosity = VerbosityLevel::getRecommendedLevelByType($exprType, $varTagType);
109106
$errors[] = RuleErrorBuilder::message(sprintf(
110107
'PHPDoc tag @var with type %s is not subtype of type %s.',
@@ -114,7 +111,7 @@ public function checkExprType(Scope $scope, Node\Expr $expr, Type $varTagType):
114111
}
115112
}
116113

117-
if (count($errors) === 0 && $containsPhpStanType) {
114+
if ($containsPhpStanType && count($errors) === 0) {
118115
$exprType = $scope->getScopeType($expr);
119116
if (!$exprType->equals($varTagType)) {
120117
$verbosity = VerbosityLevel::getRecommendedLevelByType($exprType, $varTagType);

0 commit comments

Comments
 (0)