@@ -61,6 +61,7 @@ public function __construct(
6161 public function findSpecifiedType (
6262 Scope $ scope ,
6363 Expr $ node ,
64+ bool $ ignoreTraitContext ,
6465 ): ?bool
6566 {
6667 if ($ node instanceof FuncCall) {
@@ -199,7 +200,10 @@ public function findSpecifiedType(
199200 } elseif ($ functionName === 'method_exists ' && $ argsCount >= 2 ) {
200201 $ objectArg = $ args [0 ]->value ;
201202
202- if ($ this ->isExpressionDependentOnTraitContext ($ scope , $ objectArg )) {
203+ if (
204+ $ ignoreTraitContext
205+ && $ this ->isExpressionDependentOnTraitContext ($ scope , $ objectArg )
206+ ) {
203207 $ traitReflection = $ scope ->getTraitReflection ();
204208 if ($ traitReflection === null ) {
205209 return null ;
@@ -328,7 +332,10 @@ public function findSpecifiedType(
328332 continue ;
329333 }
330334
331- if ($ this ->isExpressionDependentOnTraitContext ($ scope , $ sureType [0 ])) {
335+ if (
336+ $ ignoreTraitContext
337+ && $ this ->isExpressionDependentOnTraitContext ($ scope , $ sureType [0 ])
338+ ) {
332339 $ results [] = TrinaryLogic::createMaybe ();
333340 continue ;
334341 }
@@ -359,7 +366,10 @@ public function findSpecifiedType(
359366 continue ;
360367 }
361368
362- if ($ this ->isExpressionDependentOnTraitContext ($ scope , $ sureNotType [0 ])) {
369+ if (
370+ $ ignoreTraitContext
371+ && $ this ->isExpressionDependentOnTraitContext ($ scope , $ sureNotType [0 ])
372+ ) {
363373 $ results [] = TrinaryLogic::createMaybe ();
364374 continue ;
365375 }
0 commit comments