@@ -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